Bug #80572 [Opn->Fbk]: accessing array element that has an empty value does not work
| From: | girgias@php.net | Date: | Fri, 01 Jan 2021 19:58:15 +0000 |
| Subject: | Bug #80572 [Opn->Fbk]: accessing array element that has an empty value does not work | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-231325@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=80572&edit=1
ID: 80572
Updated by: girgias@php.net
Reported by: gkroll at keldine dot ca
Summary: accessing array element that has an empty value does
not work
-Status: Open
+Status: Feedback
Type: Bug
Package: Session related
Operating System: all
PHP Version: 7.4.13
Block user comment: N
Private report: N
New Comment:
Your test script works regardless of the PHP version: https://3v4l.org/SpuFW
So what is the actual issue (if any)?
Previous Comments:
------------------------------------------------------------------------
[2021-01-01 19:53:54] gkroll at keldine dot ca
Description:
------------
When an array element is set to the value '' (it's empty), any attempt to access the
value of that array element causes a nonsense error message:
ERROR 8: Trying to access array offset on value of type bool
Test script:
---------------
$xyz = array ('a'=>'value1', 'b'=>'',
'c'=>'value3');
var_dump ($xyz); echo '<br />'; // let's see what we have
if (isset($xyz['b'])) $foo = $xyz['b']; // no complaints here
$foo = $xyz['b']; // this crashes
echo 'foo is set to:', $foo, ': end', '<br />';
Expected result:
----------------
PHP 7.0 and earlier output:
array(3) { ["a"]=> string(6) "value1" ["b"]=> string(0)
"" ["c"]=> string(6) "value3" }
foo is set to:: end
I believe PHP 7.3 works too.
Actual result:
--------------
PHP 7.4 outputs:
ERROR 8: Trying to access array offset on value of type bool
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=80572&edit=1