In this case, I wrote a method in a class to try to call another similar method reverse in the method indexOp.
However, the error message "Fatal error: Call to undefined function reverse () in D: \ WWW \ shop \ control \ index. php on line 12" is displayed.
Of course, the prompt is that the reverse function is not defined,
But I clearly defined it. isn't there anything that doesn't comply with the regulations?
Reply to discussion (solution)
The problem is reverse (substr ($ str, 1). It is not found here.
Self: reverse (substr ($ str, 1 ));
The problem is reverse (substr ($ str, 1). It is not found here.
Self: reverse (substr ($ str, 1 ));
I tried to remove all the reverse functions. if there is only one shell left, no error is reported. but the problem is that I want to use recursion here. Is it hard to say that the class cannot write recursive methods?
Replace self: with $ this->
#1 I have clearly told you why I turned a blind eye to it?
The method becomes a function without scope.
The reason is clear. how can this problem be solved?
The problem is reverse (substr ($ str, 1). It is not found here.
Self: reverse (substr ($ str, 1 ));
Isn't he Writing self: reverse (substr ($ str, 1?
The problem is reverse (substr ($ str, 1). It is not found here.
Self: reverse (substr ($ str, 1 ));
Isn't he Writing self: reverse (substr ($ str, 1?
I tried self: or the above prompt
Paste your code, don't
Recursive call exists in method reverse!
According to the above, there is no problem.
class indexControl{public function reverse($str){if(strlen($str)>0){self::reverse(substr($str,1));echo substr($str,0,1);return;}}public function indexOp(){self::reverse("adfdsfd");}}indexControl::indexOp();
Is it affected by your framework?
In addition, if you just want to put the string upside down, you can use the strrev function without recursion.
You also have a reverse (substr ($ str, 1) method in the reverse method. if this method returns an error, change it to self: reverse (substr ($ str, 1 )); or $ this-> reverse (substr ($ str, 1 );
You also have a reverse (substr ($ str, 1) method in the reverse method. if this method returns an error, change it to self: reverse (substr ($ str, 1 )); or $ this-> reverse (substr ($ str, 1 );
Positive solution !!!!!!!!!!!!!!!!