note 56029 added to function.is-null

From: Date: Sun, 21 Aug 2005 09:57:30 +0000
Subject: note 56029 added to function.is-null
Groups: php.notes 
Request: Send a blank email to php-notes+get-93979@lists.php.net to get a copy of this message
I use is_null() to trigger warning on access of undefined object-members with php5. Consider this example: ------------------------------- class Obj { public $hello=false; } $obj = new Obj; is_null($obj->hallo) # will at least trigger a WARNING before... $obj->hallo="bla"; # ...adding a new project-member ----------------------------------- I really have a hard time to check, if an variable has been defined. The problem is, that isset() return false, if the values is defined but converted to zero. An is_defined()-function would help, but I could not find one. I know, that I could overwrite __set() but this raises other php5 issues a little but to complex to explain here. If anyone has a better way of testing on definition, PLEASE write me an mail. tom ---- Manual Page -- http://www.php.net/manual/en/function.is-null.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+56029 Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+56029&report=yes&reason=added+to+the+manual Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+56029&report=yes&reason=bad+code Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+56029&report=yes&reason=spam Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+56029&report=yes&reason=useless Delete: non-english -- http://master.php.net/manage/user-notes.php?action=delete+56029&report=yes&reason=non-english Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+56029&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+56029&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#93979) next »