M
M
Max Ba2016-03-29 17:32:54
PHP
Max Ba, 2016-03-29 17:32:54

How to call one method to another?

Guys, tell me, I don’t know where to look anymore. I need a method inside a class to be able to work inside another method. I simplified the example for understanding. Writes that the function is not declared.

class myPage
{
  private function hellow_world()
  {
    return 'hellow_world';
  }
  
  public function createPage()
  {
    return hellow_world();	
  }
}

$page = new myPage();
echo $page->createPage();

Answer the question

In order to leave comments, you need to log in

2 answer(s)
D
Dmitry, 2016-03-29
@phpcoder81

return $this->hellow_world()
Hello is written without w ;)

A
Andrey, 2016-03-29
@AndryG

I fully agree with previous speakers.

I need a method inside a class to be able to work inside another method.
Please read before posting)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question