php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #71400 null assignment as array strange results
Submitted: 2016-01-17 22:39 UTC Modified: 2016-01-17 22:57 UTC
Votes:4
Avg. Score:3.8 ± 0.8
Reproduced:2 of 2 (100.0%)
Same Version:0 (0.0%)
Same OS:2 (100.0%)
From: rav dot janisz at gmail dot com Assigned:
Status: Open Package: Arrays related
PHP Version: 5.5.31 OS: linux
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please — but make sure to vote on the bug!
Your email address:
MUST BE VALID
Solve the problem:
11 + 50 = ?
Subscribe to this entry?

 
 [2016-01-17 22:39 UTC] rav dot janisz at gmail dot com
Description:
------------
null assignment to a variable and refer to it as an array element does not return any errors

after assign null to variable var_dump return null and isset return false, but why in line 5 assign first element of $zonk variable(which is don't array and don't should exists at all) to next variable doesnt't return any errors

Test script:
---------------
$zonk = null;            //1
var_dump($zonk);         //2 return null
var_dump(isset($zonk));  //3 return false

$beret = $zonk[0];       //5 don't throw nothing ???
var_dump($beret);        //6 return null
var_dump(isset($beret)); //7 return false

Expected result:
----------------
is line 6 don't should throw something to output error or notice?
or if it is good behavior then in line 3 isset should return true?
or if i'm wrong explain why? becouse i can't figured it out


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2016-01-17 22:57 UTC] rav dot janisz at gmail dot com
-Summary: tested on 5.5.29 php version +Summary: null assignment as array strange results
 [2016-01-17 22:57 UTC] rav dot janisz at gmail dot com
wrong summary
 
PHP Copyright © 2001-2019 The PHP Group
All rights reserved.
Last updated: Mon Oct 21 16:01:26 2019 UTC