Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.php > #18942
| From | Meredith Montgomery <mmontgomery@levado.to> |
|---|---|
| Newsgroups | comp.lang.php |
| Subject | php 7.4: null["key"] |
| Date | 2022-05-20 17:34 -0300 |
| Organization | Aioe.org NNTP Server |
| Message-ID | <86mtfcq6yj.fsf@levado.to> (permalink) |
I'm upgrading code to PHP 7.4, which will now blow a notice for things
such as
null["key"]
(1.2)["key"]
(123)["key"]
All of these seem to reduce to null. (The footnote explains why I think
so.)
I have a lot of code which could be depending on such things. I'd like
to rewrite such code, but I have no idea how to find such code. I
suppose a loop such as
while ($a["key"]) { ... }
could be depending on $a sometimes being null or even being undefined
(because ``$a === null'' when $a is undefined). (These are very weird
things about PHP to my way of looking at things.)
How would you search for something like that? I just have no idea. My
best idea is to just watch a log of errors and notices and try to spot
the code that way.
(*) Footnote
I say this because of
--8<---------------cut here---------------start------------->8---
php > var_dump((123)["key"] === null);
PHP Notice: Trying to access array offset on value of type int in php
shell code on line 1
Notice: Trying to access array offset on value of type int in php shell
code on line 1
bool(true)
php >
--8<---------------cut here---------------end--------------->8---
(By the way, I don't know why I get two notices.)
Back to comp.lang.php | Previous | Next — Next in thread | Find similar | Unroll thread
php 7.4: null["key"] Meredith Montgomery <mmontgomery@levado.to> - 2022-05-20 17:34 -0300
Re: php 7.4: null["key"] Meredith Montgomery <mmontgomery@levado.to> - 2022-05-29 23:13 -0300
Re: php 7.4: null["key"] "J.O. Aho" <user@example.net> - 2022-05-30 08:06 +0200
Re: php 7.4: null["key"] Meredith Montgomery <mmontgomery@levado.to> - 2022-05-31 19:27 -0300
Re: php 7.4: null["key"] De ongekruisigde <ongekruisigde@news.eternal-september.org> - 2022-05-31 22:39 +0000
Re: php 7.4: null["key"] Meredith Montgomery <mmontgomery@levado.to> - 2022-06-02 17:26 -0300
Re: php 7.4: null["key"] Meredith Montgomery <mmontgomery@levado.to> - 2022-06-03 17:09 -0300
Re: php 7.4: null["key"] De ongekruisigde <ongekruisigde@news.eternal-september.org> - 2022-06-04 14:35 +0000
csiph-web