What does {0} mean in a PHP expression?

Apolit, if asked earlier. I am using another PHP code and find the following line:

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

If, $ _GET and die I understand, but what is the value of {0} after $ _GET ['file']? I looked through a number of guides and could not find an answer.

TIA.

+3
source share
4 answers

$str{0}will return the first character / byte of the string. But the syntax is $str{0}deprecated in favor of$str[0] :

Note. Strings can also be accessed using curly braces, as in $str{42}, for the same purpose. However, this syntax has been deprecated since PHP 5.3.0. Use square brackets instead, for example $str[42].

If you work with multibyte characters, use mb_substr.

+11

{0} [0]. , $_GET['file']{0} $_GET['files'].

+5

. $_GET ['file'] {1} . , , , ; , URL-, ../../../etc/passwd.

+4

, 0 $_GET ['file'] , .

( ) , , , .

+1

Source: https://habr.com/ru/post/1765122/


All Articles