[英]number as variable name in php
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字符串:
$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"};
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.