php - 这个 PHP 语法是什么意思?

标签 php syntax

考虑代码:

$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/

相关文章:

c++ - 抽象类 - 语法帮助

javascript - 在 jQuery 自动完成中获取动态值

php - mysql wordpress php 语法错误

r - R 中复合语句中的奇怪错误? : "target of assignment expands to non-language object"

database - 如何解决 flutter sqlite 语法错误?

php - 首先从下到上加载最新帖子

php - 由于JQuery Ajax Post导致的500内部服务器错误

PHP/MySQL : Insert rows temporarily

php - 比较一个数组中的数组值 PHP

php - Symfony/验证器 : Property validation in Callback