note 41305 added to function.is-a

From: Date: Tue, 06 Apr 2004 05:01:24 +0000
Subject: note 41305 added to function.is-a
Groups: php.notes 
Request: Send a blank email to php-notes+get-67690@lists.php.net to get a copy of this message
I suggest a small change to hendrix's code below, should someone decide to implement this unusual pattern. Using isset() instead of is_a() will prevent a E_NOTICE from being generated, if it is turned on. It is otherwise functionally equivalent. <?php class MyClass { function method() { if (isset($this)) { echo "static\n"; } else { echo "instance\n"; } } } echo "<pre>"; MyClass::method(); $m = new MyClass(); $m->method(); ?> code till dawn, mark meves ---- Manual Page -- http://www.php.net/manual/en/function.is-a.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+41305 Delete -- http://master.php.net/manage/user-notes.php?action=delete+41305&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+41305&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#67690) next »