title: PHP, distinguish between internal and external class method call
body: <p>Can't get my head around this, is there any way to check if a method was called internally? By this I mean a traceback to check if it was called by $this and not a pointer to the instance. Kind of like the concept of private function but only function is public?</p>
  
  <pre><code>&lt;?php
  
  class Foo {
      public function check () {
          /*
          if invoked by $this (internally)
              return true
          else
              return false
          */
      }
  
      public function callCheck () {
          /* returns true because its called by $this */
          return $this-&gt;check();
      }
  }
  
  $bar = new Foo;
  // this should return false because we are calling it from an instance
  $bar-&gt;check();
  // where as this will return true
  $bar-&gt;callCheck();
  
  ?&gt;
  </code></pre>
  
  <p>Maybe this is undo-able but I really need it for my project at university? Anyone come across a solution or knows how I would identify a solution.</p>
  
  <p>Thanks.</p>