Hutarsh
Hutarsh

Reputation: 679

PHP offset warning on null

I should be getting an offset warning error in this code but it shows nothing. What am i missing ?

I have turned on error reporting etc.

<?php
$info = null;
$value = 'string';
if ($value == $info['firstname']){
 echo 'true';
}else{
 echo 'false';
}
?>

Upvotes: 2

Views: 62

Answers (1)

freeek
freeek

Reputation: 978

Prior to version 7.4 Undefined index throws for arrays only:

<?php
$info = [];
$value = 'string';
if ($value == $info['firstname']) {
 echo 'true';
} else {
 echo 'false';
}
?>

Upvotes: 3

Related Questions