[ create a new paste ] login | about

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

PHP, pasted on Feb 21:
<?php

// Global function

$a = 'max';

echo call_user_func($a, 1, 2);
echo $a(1, 2);

// Class method

class A {

   public function b() {
     return __CLASS__;
   }

   static function c() {
      return 'I am static!';
   }

}

$a = new A;
$b = 'b';

echo call_user_func(array($a, $b));
echo $a->$b();

// Static class method

$c = 'c';


echo call_user_func(array('A', $c)); // I am static!
echo a::$c();


Output:
1
22AAI am static!I am static!


Create a new paste based on this one


Comments: