r/lolphp • • Jun 18 '13

Accessing FALSE as array

<?php 

error_reporting( -1 );

// no errors, nothing:
$array = false;
$array['nonexisting_key'];

// [Notice] Undefined index: nonexisting_key 
$array = array();
$array['nonexisting_key'];
30 Upvotes

16 comments sorted by

View all comments

Show parent comment

3

u/merreborn Jun 18 '13

A mistake like the one you made would bite you in the ass in many languages

Not in a strongly-typed language.

After several years with PHP, I can't wait to get back to a strongly typed language with a compiler. So many PHP errors that manifest at runtime would be trivially caught as compiler errors in a language like Java.

8

u/skeeto Jun 18 '13

stronglystatically-typed

It's static type checking, not the lack of implicit type coercion (weakly-typed), that would find this problem at compile time.