Jump to content

[SOLVED] OOP call method within itself


MasterACE14

Recommended Posts

Hello,

 

I have a class and 2 methods, the first method I want it to be recursive within itself. This works fine for the method as a standalone function not in a class. But I have no idea how to make it recursive when it is within the class.

 

like for example(very poor example)...

function hello($arg=null) {
  $arg = "Hello";
  hello($arg);
}
// without class

 

however how can I do the same within a class like...

class something {
public $arg;
function hello($arg=null) {
  $arg = "Hello";
  hello($arg);
}
}

$obj = new something;
$obj->hello();

 

thanks in advance.

 

ACE

Link to comment
https://forums.phpfreaks.com/topic/162370-solved-oop-call-method-within-itself/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.