我正在测试将 UTF-8 字符串转换为 php 变量的 json_decode 函数,
我不明白为什么这不起作用
$names='array("Jack","Jill","John")'
$convert_names=json_decode($names);
echo echo $convert_names[0];
但这有效
$names='["Jack","Jill","John"]'
$convert_names=json_decode($names);
echo echo $convert_names[0];
我了解到创建 PHP 数组的方法是
$names=array("Jack","Jill","John") // this works
$names=["Jack","Jill","John") //this does not work
为什么在涉及 JSON_DECODE 函数时会如此不同