Why script
<?php $x="2"; $y="3"; $z="\x$x$y"; echo $z; ?> Print the string \x23 , not the # character? How does variable substitution in a string work in PHP ?
Print the string \x23 , not...">
I thought that the interpreter FIRST substituted the value of the variables $ x and $ y, and THEN starts reading the newly received string, sees \ x23 and thinks "yes this is the # symbol". and put him there
No, interpolation is always done in a single pass. At least from the considerations of elementary logic: multi-pass interpolation can (and will) lead to unpredictable results, which are simply not foreseeable in most cases. Not to mention the fact that it will slow down the work of the interpreter, and most importantly, it is simply not necessary.
So in the simplest case, a banal string substitution is made and nothing else. Details are described in the PHP manual, section "Variable Processing" .
In more complex cases, sets of rules are used, which are described in the section “Complex (curly) syntax” there.
Source: https://ru.stackoverflow.com/questions/587185/
All Articles
#should be displayed? - PinkTux