Re: How to do type/existence checking in PHP5

From: Date: Fri, 23 Apr 2004 10:51:02 +0000
Subject: Re: How to do type/existence checking in PHP5
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-184376@lists.php.net to get a copy of this message
I don't understand the question. One should always check the existence of something before attempting to use it. If (isset($var) && gettype($var) == "boolean") is one way of type checking. "Christian Jul Jensen" <christian@jul.net> wrote in message news:87llknuifq.fsf@noah.jul.net... > Hi > > In PHP5 the behaviour of illegal string offsets has changed. This is > documented in the 'thin changes' file. > > This gives a problem in checking for existence / types of values, > directly into a deeper level of a multidimensional array. > > I reported this as a bug[1] because I find the behaviour unfortunate, and > furthermore it's inconsistent. This was refused, with a note 'So don't > do it'. I think it's a really bad idea not to check the > existence/types of values, before using them, so how should this be done > properly in PHP5, without risking fatal errors in the case of a > non-existent array? > > This is a problem in migrating applications from PHP4 because the > error will not appear unless the value deosn't exist, which is exactly > why you do the check. > > [1] http://bugs.php.net/bug.php?id=28107 > > -- > ./mvh Christian Jul Jensen > Frelance webprogrammer > TYPO3 Typehead Denmark

« previous php.general (#184376) next »