note 62315 deleted from language.operators.type by colder

From: Date: Sat, 24 Feb 2007 10:03:08 +0000
Subject: note 62315 deleted from language.operators.type by colder
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-123812@lists.php.net to get a copy of this message
Note Submitter: arnold at bean-it dot nl ---- Note that operator 'instanceof' will trigger the autoloader. If the class does not exists, it is not possible that the object is an instance of this class (as shown by glen at arkadia-systems dot com). Loading this class will probably be a waste of excecution time, so use class_exists with $autoload set to false before using instanceof. <?php function __autoload($classname) { if (($fp = @fopen("$classname.php", 'r', 1)) and fclose($fp)) include_once "$classname.php"; } function foo($obj) { if (class_exists('ABC', false) && $obj instanceof ABC) echo "object is an ABC"; } ?>

« previous php.notes (#123812) next »