note 126861 added to functions.variable-functions

From: Date: Sat, 19 Feb 2022 06:38:16 +0000
Subject: note 126861 added to functions.variable-functions
Groups: php.notes 
Request: Send a blank email to php-notes+get-217628@lists.php.net to get a copy of this message
<?php static bar method works with statically or non statically wherese non static method could not work statically //non static method class myCls{ public function foo(){ echo "foo function"; } static public function bar(){ echo "static bar function"; } } $a = new myCls; $myf = "foo"; $a->$myf();//works echo "\n"; $a = [new myCls,"foo"];//works $a(); echo "\n"; //$a = ["myCls","foo"];//fatal error //$a(); echo "\n"; //$a = "myCls::foo";//fatal error //$a(); echo "\n"; //static method called with statically or nonstatically $b = new myCls; $myf = "bar"; $b->$myf();//works echo "\n"; $b = [new myCls,"bar"];//works $b(); echo "\n"; $b = "myCls::bar";//works $b(); echo "\n"; $b = ["myCls","bar"];//works $b(); echo "\n"; ---- Server IP: 45.112.84.4 Probable Submitter: 80.90.5.135 (proxied: 103.120.33.26) ---- Manual Page -- https://php.net/manual/en/functions.variable-functions.php Edit -- https://main.php.net/note/edit/126861 Del: integrated -- https://main.php.net/note/delete/126861/integrated Del: useless -- https://main.php.net/note/delete/126861/useless Del: bad code -- https://main.php.net/note/delete/126861/bad+code Del: spam -- https://main.php.net/note/delete/126861/spam Del: non-english -- https://main.php.net/note/delete/126861/non-english Del: in docs -- https://main.php.net/note/delete/126861/in+docs Del: other reasons-- https://main.php.net/note/delete/126861 Reject -- https://main.php.net/note/reject/126861 Search -- https://main.php.net/manage/user-notes.php

« previous php.notes (#217628) next »