note 122004 added to function.call-user-method

From: Date: Mon, 11 Dec 2017 07:59:17 +0000
Subject: note 122004 added to function.call-user-method
Groups: php.notes 
Request: Send a blank email to php-notes+get-209346@lists.php.net to get a copy of this message
<?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! ---- Server IP: 208.43.231.9 Probable Submitter: 103.202.223.116 ---- Manual Page -- http://php.net/manual/en/function.call-user-method.php Edit -- https://master.php.net/note/edit/122004 Del: integrated -- https://master.php.net/note/delete/122004/integrated Del: useless -- https://master.php.net/note/delete/122004/useless Del: bad code -- https://master.php.net/note/delete/122004/bad+code Del: spam -- https://master.php.net/note/delete/122004/spam Del: non-english -- https://master.php.net/note/delete/122004/non-english Del: in docs -- https://master.php.net/note/delete/122004/in+docs Del: other reasons-- https://master.php.net/note/delete/122004 Reject -- https://master.php.net/note/reject/122004 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#209346) next »