考虑代码:
$a = "foobar";
echo $a{3}; // prints b
我知道 $a[3]
是 'b'
但为什么要用 {}
代替 []
产生相同的结果?
最佳答案
您可以阅读 here in official documentation关于大括号:
String s may also be accessed using braces, as in $str{42}, for the same purpose. However, this syntax is deprecated as of PHP 5.3.0. Use square brackets instead, such as $str[42].
关于php - 这个 PHP 语法是什么意思?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3203335/