note 97789 added to function.method-exists

From: Date: Sat, 08 May 2010 12:20:43 +0000
Subject: note 97789 added to function.method-exists
Groups: php.notes 
Request: Send a blank email to php-notes+get-169070@lists.php.net to get a copy of this message
If you want to check in a class itself if a method is known you may do so with magic variable __CLASS__ <?php class A{ __construct($method){ return method_exists(__CLASS__,$method); } private function foo(){ } } $test = new A('foo'); //should return true ?> You might also use the method describe below with <?php in_array() ?> trick but I consider this one here easier and more readable and well, the way it is intended toi be done ;) ---- Server IP: 69.147.83.197 Probable Submitter: 87.156.183.210 ---- Manual Page -- http://www.php.net/manual/en/function.method-exists.php Edit -- https://master.php.net/note/edit/97789 Del: integrated -- https://master.php.net/note/delete/97789/integrated Del: useless -- https://master.php.net/note/delete/97789/useless Del: bad code -- https://master.php.net/note/delete/97789/bad+code Del: spam -- https://master.php.net/note/delete/97789/spam Del: non-english -- https://master.php.net/note/delete/97789/non-english Del: in docs -- https://master.php.net/note/delete/97789/in+docs Del: other reasons-- https://master.php.net/note/delete/97789 Reject -- https://master.php.net/note/reject/97789 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#169070) next »