note 119222 added to functions.variable-functions

From: Date: Thu, 21 Apr 2016 17:58:09 +0000
Subject: note 119222 added to functions.variable-functions
Groups: php.notes 
Request: Send a blank email to php-notes+get-205298@lists.php.net to get a copy of this message
A small, but helpful note. If you are trying to call a static function from a different namespace, you must use the fully qualified namespace, even if they have the same top level namespace(s). For example if you have the following class to call: <?php namespace Project\TestClass; class Test { static function funcToCall() { return "test"; } } ?> You must call it as: <?php namespace Project\OtherTestClass; class OtherTest { static function callOtherFunc() { $func = '\Project\TestClass::funcToCall'; $func(); } } ?> and not: <?php class OtherTest { static function callOtherFunc() { $func = 'TestClass::funcToCall'; $func(); } } ?> ---- Server IP: 72.52.91.14 Probable Submitter: 207.255.250.22 ---- Manual Page -- http://php.net/manual/en/functions.variable-functions.php Edit -- https://master.php.net/note/edit/119222 Del: integrated -- https://master.php.net/note/delete/119222/integrated Del: useless -- https://master.php.net/note/delete/119222/useless Del: bad code -- https://master.php.net/note/delete/119222/bad+code Del: spam -- https://master.php.net/note/delete/119222/spam Del: non-english -- https://master.php.net/note/delete/119222/non-english Del: in docs -- https://master.php.net/note/delete/119222/in+docs Del: other reasons-- https://master.php.net/note/delete/119222 Reject -- https://master.php.net/note/reject/119222 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#205298) next »