title: How can I call a method into a function of another method?
body: <p><a href="https://3v4l.org/E1U9n" rel="nofollow noreferrer">Here</a> is my code:</p>
  
  <pre><code>class myclass{
  
      public function one(){
          return 'sth';
      }
  
      public function two(){
          function myfunc($arg){
              if ($arg){
                  return $this-&gt;one();
              } else {
                  return 'nothing';
              }
              myfunc(true);
          }
      }
  }
  
  $obj = new myclass;
  echo $obj-&gt;$this-&gt;two();
  </code></pre>
  
  <p>As you see in the fiddle it throws this error:</p>
  
  <blockquote>
    <p>Fatal error: Uncaught Error: Using $this when not in object context in /in/E1U9n:25</p>
  </blockquote>
  
  <p>How can I fix the problem?  The expected result is <code>sth</code>.</p>