note 122004 deleted from function.call-user-method by cmb

From: Date: Sun, 25 Oct 2020 13:15:16 +0000
Subject: note 122004 deleted from function.call-user-method by cmb
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-215639@lists.php.net to get a copy of this message
Note Submitter: bmafzallmahmud at gmail dot com ---- <?php call_user_method() This function was DEPRECATED in PHP 4.1.0, and REMOVED in PHP 7.0.0. Alternatives to this function include : call_user_func() example :01 class Habib { static public function test() { print "Hello Hasina!<br>"; } } call_user_func('Habib::test'); call_user_func(array('Habib', 'test')); //this class no __NAMESPACE__ dut we use and find the result call_user_func(__NAMESPACE__ .'\Habib::test'); call_user_func(array(__NAMESPACE__ .'\Habib', 'test')); $classname = "Habib"; call_user_func(array($classname, 'test')); call_user_func($classname .'::test'); $myobject = new Habib(); call_user_func(array($myobject, 'test')); call_user_func($myobject .'::test'); //Recoverable fatal error : Object of class Foo could not be converted to string output: Hello Hasina! Hello Hasina! Hello Hasina! Hello Hasina! Hello Hasina! Hello Hasina! Hello Hasina! Recoverable fatal error : Object of class Foo could not be converted to string example:02 -------------------------------------------------------------------------- namespace Foobar; class Habib { static public function test() { print "Hello Hasina!<br>"; } } call_user_func(__NAMESPACE__ .'\Habib::test'); call_user_func(array(__NAMESPACE__ .'\Habib', 'test')); $myobject = new Habib(); call_user_func(array($myobject, 'test')); output: Hello Hasina! Hello Hasina! Hello Hasina!

« previous php.notes (#215639) next »