K
K
khodos_dmitry2018-03-10 19:16:06
PHP
khodos_dmitry, 2018-03-10 19:16:06

Why doesn't this record $limit = "Limit {$limit+5}" work?

Gives an error: Parse error: syntax error, unexpected '+', expecting '}'
Is it possible to perform arithmetic operations somehow in a string?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Anatoly Medvedev, 2018-03-10
@balamyt92

because you can't do that php.net/manual/en/language.types.string.php#langua...

D
Dmitry Entelis, 2018-03-10
@DmitriyEntelis

Using double quotes and curly braces is bad design.
Write normally:
$limit = 'Лимит ' . ($limit+5);

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question