php undefined index or variables don't throw any error

222 views Asked by At

I came across a fat-free framework where indexes are accessed without checking if there's data present or not.

few e.g.

e.g.1 
$sObj = new Site($db); // this returns null?
$site = $sObj->getById($sessionSiteId)[0];

e.g.2
$ppObject = new Page($db);
$pheader = $ppObject->getByCodeandsiteid($siteid,'Header');        
F3::set('headercode',$pheader[0]['description']);

so these are just few cases. Most of the practice done is to just access the index. This throws error in my env. php 8.1 and fat-free 3.8.1.

But running this same code on my colleague's env. : php 5.6.40 and fat-free 3.5.1` this doesn't throw error but simply gives null value.

I also checked with some random unassigned variable on his env. and to my surprise, this also seem to simply give null instead of error.

Is this expected behavior on previous versions?

Also checked in phpinfo() that error_reporting value for both is 22527.

0

There are 0 answers