note 62315 added to language.operators.type

From: Date: Fri, 24 Feb 2006 23:28:56 +0000
Subject: note 62315 added to language.operators.type
Groups: php.notes 
Request: Send a blank email to php-notes+get-104387@lists.php.net to get a copy of this message
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"; } ?> ---- Server IP: 83.137.20.120 Probable Submitter: 213.84.27.165 ---- Manual Page -- http://www.php.net/manual/en/language.operators.type.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+62315 Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+62315&report=yes&reason=added+to+the+manual Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+62315&report=yes&reason=bad+code Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+62315&report=yes&reason=spam Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+62315&report=yes&reason=useless Delete: non-english -- http://master.php.net/manage/user-notes.php?action=delete+62315&report=yes&reason=non-english Delete: already in docs -- http://master.php.net/manage/user-notes.php?action=delete+62315&report=yes&reason=already+in+docs Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+62315&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+62315&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#104387) next »