Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fatal error: Curly braces? #38

Open
RandomTurtle opened this issue May 12, 2024 · 2 comments
Open

Fatal error: Curly braces? #38

RandomTurtle opened this issue May 12, 2024 · 2 comments

Comments

@RandomTurtle
Copy link

RandomTurtle commented May 12, 2024

Fatal error: Array and string offset access syntax with curly braces is no longer supported in D:\D\htdocs\index.php on line 180

what's a curly braces?

I replaced the $_iflags{$i} with $_iflags[$i] but now the page loads as a blank white page.

@Quix0r
Copy link

Quix0r commented Sep 9, 2024

A curly brace {} is for function/method or whole class bodies. It also is for enclosing code in if() or else() blocks and other control/loop blocks, like while(), for(), foreach() et cetera. Replacing them with brackets ([]) will tell PHP to interpret $_iflags as an array. A white empty page indicates a fatal error which means you should reverse your changes and check log files.

@Quix0r
Copy link

Quix0r commented Sep 9, 2024

$_iflags is of type string here and access on its parts also known as "sub-strings" through curly braces is no longer supported by newer PHP versions. Someone needs to rewrite this code to use substr() instead.

Plus all these type castings (int)(bool) looks odd to me.

Here is a wonderful article about it:
https://stackoverflow.com/questions/59158548/array-and-string-offset-access-syntax-with-curly-braces-is-deprecated

And yes, you can use $string[$pos] syntax instead. I get an exit code 255 here with [] instead of {}.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants