gpt4 book ai didi

php - {0} 在 PHP 语句中是什么意思?

转载 作者:可可西里 更新时间:2023-10-31 23:52:50 27 4
gpt4 key购买 nike

Apols 如果之前有人问过这个问题。我正在使用其他人的 PHP 代码并遇到以下行:

if($_GET['file']{0}=='.') die('Wrong file!');

if、$_GET 和 die 我明白了,但是 $_GET['file'] 后面的 {0} 是什么意思?我浏览了很多教程,但没有找到答案。

TIA。

最佳答案

$str{0} 将返回字符串的第一个字符/字节。但是the syntax $str{0} is deprecated in favor of $str[0] :

Note: Strings 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].

如果您使用的是多字节字符,请使用 mb_substr相反。

关于php - {0} 在 PHP 语句中是什么意思?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3727798/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com