Can I write a custom function in the member method of PHP?
I defined the function in a method, but the error was called
This is the method of error.
The error is as follows
But I also have another way to write the function and recursive, but there is no error.
This is the interface that calls these two methods
Why did you get an error? Who can explain, or have a good way to deal with it.
Reply content:
Can I write a custom function in the member method of PHP?
I defined the function in a method, but the error was called
This is the method of error.
The error is as follows
But I also have another way to write the function and recursive, but there is no error.
This is the interface that calls these two methods
Why did you get an error? Who can explain, or have a good way to deal with it.
Why not write your custom function as a member method within a class?
Thank you, you can customize the error here because you have defined the Gettree function elsewhere, the error is that you repeat the definition.
There is also a better choice of PHP closures, probably as follows:
class Test{ public function index(){ $hello_closures = function ($str){ echo $str; }; $hello_closures("hello , php closures function"); }}
Official documents look here, very easy to understand: Http://php.net/manual/zh/func ...
The error message is already obvious, you cannot define the Gettree function repeatedly, you have already defined it in Labelcontroller
The functions in PHP (not the method of the Class) are global, that is, whether you are defined in the global, or functions defined in the function, are considered global (this is not the same as JS, do not confuse).
PHP does not support function overloading (that is, cannot duplicate the name), so it is not allowed to repeat the function (speaking of overloading, but in the class can be implemented, but the meaning is completely different, it feels like the error handler function, just for the friendly display, personally feel, no eggs).