For instance, the following will not print "hello john_doe"
as desired, since $first_
is not defined.
$first = 'john';
$last = 'doe';
echo "hello $first_$last";
Maybe there are none?
For instance, the following will not print "hello john_doe"
as desired, since $first_
is not defined.
$first = 'john';
$last = 'doe';
echo "hello $first_$last";
Maybe there are none?
Any character that cannot be part of a variable name can be used there - if the character can be part of the variable name, PHP cannot determine whether it's part of it or not...
According to the manual:
Variable names follow the same rules as other labels in PHP. A valid variable name starts with a letter or underscore, followed by any number of letters, numbers, or underscores. As a regular expression, it would be expressed thus: '[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*'
So, to answer your question: any character other than a letter, a number, or an underscore can immediately follow a parsed PHP variable using simple syntax...
(Note that special characters like ƒ
, ©
, √
, etc... fall under that \x7f-\xff
UTF-8 range in the regexp and are valid characters).
With some exceptions - e.g., you can't use:
[
because it's considered an access to an array key.{$
because it's considered as an attempt to use a variable (e.g., {$var}
).->
followed by a character that can be part of a variable, because it's considered an access to a property (e.g., ->prop
).