0

For any of the following cases, there is no undefined offset notice or any kind of notice:

$var1 = true;
$var2 = $var1[4];

$var1 = null;
$var2 = $var1[4];

$var1 = 1234;
$var2 = $var1[4];

All of these cases are invalid codes and one would expect PHP to throw some kind of notice. Is there a reason for not throwing error or is this just of those PHP weirdness?

kmdhrm
  • 505
  • 1
  • 6
  • 17
  • 1
    Possible duplicate of [PHP: "Notice: Undefined variable", "Notice: Undefined index", and "Notice: Undefined offset"](https://stackoverflow.com/questions/4261133/php-notice-undefined-variable-notice-undefined-index-and-notice-undef) – Pradeep May 15 '18 at 05:54
  • php allows you to access a string like an array with the [] syntax –  May 15 '18 at 05:56

0 Answers0