Forum Moderators: coopster

Message Too Old, No Replies

Irritating warning from PHP 7.4

         

csdude55

5:48 am on Dec 31, 2020 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Well, I found this one out today when I saw my error log was almost 6G >:-(

So apparently, PHP 7.4 has arbitrarily decided to deprecate the use of { } for arrays. Which I have used for environment variables since Hector was a pup.

PHP Deprecated: Array and string offset access syntax with curly braces is deprecated in /home/blah/blah/blah.php


So now I get the fun little job of going through 50 bajillion pages to change them. WHY, PHP?! Was it really that big of a deal?

robzilla

8:08 am on Dec 31, 2020 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Didn't even know it was possible to use curly braces for that. It's never been the official way, and it's not really documented either. Apparently [wiki.php.net] it's been deprecated since PHP 5.1 RC5, but they only recently enabled the deprecation warning. They link to a migration script you could use there.

csdude55

6:00 pm on Dec 31, 2020 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



I started using PHP sometime around 2008, and for whatever reason I was using environment variables with { } and all other arrays were using [ ]. I guess it was because I was coming from more of a Perl background, so it seemed more normal? Or more likely, I'd read an article somewhere that listed ENV variables and used curlies, so I picked it up from there.

The warning says it will throw an error in the future, so I might as well deal with it now. I'm just irritated at all of the seemingly minor things that I'm having to deal with because of the update; like, why couldn't they just support the curlies? Why not create basic functions to make mysql_ commands automatically load mysqli_ if the database was connected via mysqli? It seems like such a minor thing they could have done that would have saved me days (weeks) of work.

lucy24

7:20 pm on Dec 31, 2020 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



:: panicked run to nearest navigation header ::

Whew. No curly braces in sight.

w3dk

1:37 am on Jan 1, 2021 (gmt 0)

10+ Year Member Top Contributors Of The Month



I started using PHP sometime around 2008


Coincidentally, it seems the curly brace syntax was very nearly deprecated at around the same time, but it just didn't make the final release of PHP 5.1. [wiki.php.net...]

why couldn't they just support the curlies?


It would seem to be "just" for consistency.

(But it was partly the inconsistent nature of PHP that gave it a bad name.)