function ref_other_class($t)
{
    $obj = new TestClass();
    $other = new OtherClass();
    $obj->other = $other;
    $obj->register_hook();
    $obj->other->register_hook();
    $r = $obj->run_hook(4);
    $t->is($r, 22);
    $obj->clear_hook();
    $other->clear_hook();
}
 public function sayHello(namespace\SomeOtherClass $class, $ref)
 {
     echo 'hello world';
     $x = new OtherClass();
     $y = $x;
     $y->hello();
     OtherClass::world();
     $y::world();
 }
<?php

#Example #3 Calling a parent's method
class MyClass
{
    protected function myFunc()
    {
        echo "MyClass::myFunc() in parent \n";
    }
    protected function myFunc2()
    {
        echo "MyClass::myFunc2() in parent \n";
    }
}
class OtherClass extends MyClass
{
    // Override parent's definition
    public function myFunc()
    {
        // But still call the parent function
        parent::myFunc();
        echo "OtherClass::myFunc()\n";
        $this->myFunc2();
    }
}
$class = new OtherClass();
$class->myFunc();
<?php

#Example #1 :: from outside the class definition
class MyClass
{
    const CONST_VALUE = 'A constant value in parent ';
}
#Example #2 :: from inside the class definition
class OtherClass extends MyClass
{
    public static $my_static = 'static var in child';
    public static function doubleColon()
    {
        echo parent::CONST_VALUE . "\n";
        echo self::$my_static . "\n";
    }
}
$classname = 'OtherClass';
echo $classname::doubleColon();
// As of PHP 5.3.0
OtherClass::doubleColon();
 function fow(OtherClass $otherClass)
 {
     $otherClass->world();
 }