number as variable name not possible right? But this works
${4} = 444;
echo ${4};
Question: How much is this justified using this syntax? and where is info about this in documentation? I not found.
The syntax is covered in Variable variables . No, you are not "justified" in using this syntax. You should absolutely never do this , there is no good reason for using a number as a variable name.
Variables between brackets are considered valid (variable variables), no matter the syntax.
${'sad asda sda'} = 444;
echo ${'sad asda sda'};
// still works.
this is also works
$_4 = 444;
echo $_4; //output 444.
This is a perfectly ok json string:
$json_str = '{"1": "One", "02": "Two"}';
So if I were to decode it:
$json_object = json_decode($json_str);
the way to access the elements is:
$one = $json_object->{1};
$two = $json_object->{"02"};
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.