This is probably a really simple question however Google isn't my friend today.
I have something like this but it says call to undefined function
<?php class myClass{ function doSomething($str){ //Something is done here } function doAnother($str){ return doSomething($str); } } ?>
In this program, you have to first make a class name 'CallingMethodsInSameClass' inside which you call the main() method. This main() method is further calling the Method1() and Method2(). Now you can call this as a method definition which is performing a call to another lists of method.
Calling a function from within itself is called recursion and the simple answer is, yes.
You need to call newTest to make the functions declared inside that method “visible” (see Functions within functions). But that are then just normal functions and no methods. Show activity on this post.
Try the following:
return $this->doSomething($str);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With