note 50332 added to keyword.paamayim-nekudotayim

From: Date: Thu, 24 Feb 2005 23:04:57 +0000
Subject: note 50332 added to keyword.paamayim-nekudotayim
Groups: php.notes 
Request: Send a blank email to php-notes+get-85505@lists.php.net to get a copy of this message
Carrying on from the previous note, it is possible to call a member function statically using a variable for the name of the class, i.e.: <?php class MyObject { function myfunc() { return "Hello! ($this)"; // '$this' to determine whether it is being called statically } } $type = "MyObject"; $object = new $type(); $message = $object->myfunc(); $message = MyObject->myfunc(); $message = call_user_func(array(&$type, "myfunc")); O.K., so it's not using the scope resolution operator, but it does what you want... it calls 'myfunc' statically from the class named by $type. ---- Manual Page -- http://www.php.net/manual/en/keyword.paamayim-nekudotayim.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+50332 Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+50332&report=yes&reason=added+to+the+manual Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+50332&report=yes&reason=bad+code Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+50332&report=yes&reason=spam Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+50332&report=yes&reason=useless Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+50332&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+50332&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#85505) next »