NYCPHP Meetup

NYPHP.org

[nycphp-talk] Accessing non-existent array elements ok?

Michael B Allen ioplex at gmail.com
Sun Aug 17 16:49:02 EDT 2008


I seem to recall getting a warning trying to access array elements
that did not exist but I can't seem to trigger that issue right now.

The following code:

  <?php
  $a = array('a' => 'b');
  $result = $a['c'];
  var_dump($result);

yields the following:

  $ php -f t.php
  NULL

Is it ok to access non-existent array elements?

Will accessing an array element using a key that does not exist always
return NULL?

Mike



More information about the talk mailing list