<?php
class Bar {
   private $_foo;

   public function __construct($fooVal) {
      $this->_foo = $fooVal;
   }

   public function printFoo() {
      print $this->_foo;
   }

   public static function sayHello($name) {
      print "Witaj, $name!";
   }
}
// funkcja nienaleca do klasy Bar
function printCount($start, $end) {
   for($x = $start; $x <= $end; $x++) {
      print "$x ";
   }
}

// wypisuje 1 2 3 4 5 6 7 8 9 10
call_user_func('printCount', 1, 10);                  /* przykad 1 */

// wywouje $objBar->printFoo()
$objBar = new Bar('so'); call_user_func(array($objBar, 'printFoo'));
                                                      /* przykad 2 */

// wywouje Bar::sayHello('Adam')
call_user_func(array('Bar', 'sayHello'), 'Adam');     /* przykad 3 */

// Zwraca krytyczny bd "Using $this when not
// in object context", poniewa nastpuje prba wywoania
// Bar::printFoo, a printFoo nie jest metod statyczn
call_user_func(array('Bar', 'printFoo'));             /* przykad 4 */
?>