خرید بک لینک

Vote count: 0

I'm trying to call a function in a static class variable but I have some problems

This is the minimal example

 #!/usr/bin/php
<?php

class Foo {
  public static $func;

  public static function call() {
    echo "calling funcn";
    if ( isset(self::$func) &&
         is_callable(self::$func))
      self::$func();
    else echo "no calln";
  }
}


Foo::call();

Foo::$func();

Foo::call();

?>

It gives me the following output

calling func
no call
PHP Notice:  Undefined variable: func in /home/edwin/hola.php on line 19
PHP Fatal error:  Function name must be a string in /home/edwin/hola.php on line 19

asked 43 secs ago

برچسب: نویسنده: استخدام کار تاريخ: يکشنبه 15 فروردين 1395 ساعت: 8:07

صفحه بندی