[ create a new paste ] login | about

Link: http://codepad.org/jsTLnQvS    [ raw code | output | fork ]

PHP, pasted on Mar 17:
<?php
class A {
  public function printName() {
   printf('I am: "%s" called from "%s".%s', get_class($this), __CLASS__, "\n");
  }
 
  public function foo() {
    return A::printName();
  }
}
 
class B {
  public function foo() {
    A::printName();
  }
}
 
$a = new A();
$a->foo();
 
$b = new B();
$b->foo();


Output:
1
2
I am: "A" called from "A".
I am: "B" called from "A".


Create a new paste based on this one


Comments: