How to instantiate from a string class name in PHP? -
How to create a new example of return names? Unfortunately, I get this error:
Error: Class name should be a valid object or string
This is my code:
square fu {public function selClass () {return 'home ()'; }} $ Foo = New Foo (); $ Bar = new $ foo- & gt; Cell class ();
It looks like you're looking for something like this:
Class Home {Public Function Run () {Return 'Hello World'; }} Square fu {public function selClass () {return 'home'; }} $ Foo = New Foo (); $ Bar class = $ foo- & gt; Cell class (); $ Bar = new $ bar class; Revert $ Bar- & gt; Play (); // Hello World
Note that the code you specify should be named
selClass alone, without brackets, and that after bracket
$ BarClass are optional.
Comments
Post a Comment