note 49613 added to function.is-object

From: Date: Thu, 03 Feb 2005 01:07:00 +0000
Subject: note 49613 added to function.is-object
Groups: php.notes 
Request: Send a blank email to php-notes+get-84402@lists.php.net to get a copy of this message
Thank you victor AT fourstones DOT net. I have written a function to do what victor has suggested, with the ease of use of is_object. It can be used to replace is_object(), but has an extra field [$check], to compare to a certain name. If $check is left empty, it will just check if &$object is an object. <?php function is_obj( &$object, $check=null, $strict=true ) { if( $check == null && is_object($object) ) { return true; } if( is_object($object) ) { $object_name = get_class($object); if( $strict === true ) { if( $object_name == $check ) { return true; } } else { if( strtolower($object_name) == strtolower($check) ) { return true; } } } } ?> This could probably be cleaned up, but it's spaced out to be easy to read. ---- Manual Page -- http://www.php.net/manual/en/function.is-object.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+49613 Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+49613&report=yes&reason=added+to+the+manual Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+49613&report=yes&reason=bad+code Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+49613&report=yes&reason=spam Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+49613&report=yes&reason=useless Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+49613&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+49613&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#84402) next »