0
に、私はクラスの静的変数に関数を呼び出すしようとしているが、私はこれは、それは私に次のような出力を提供しますは、静的メンバ変数
#!/usr/bin/php
<?php
class Foo {
public static $func;
public static function call() {
echo "calling func\n";
if (is_callable(self::$func))
self::$func();
else echo "no call\n";
}
}
Foo::call();
Foo::$func = function() { echo "hello\n"; };
Foo::call();
?>
最小限の一例であるいくつかの問題
を持つ関数を呼び出す
calling func
no call
calling func
PHP Notice: Undefined variable: func in /home/edwin/hola.php on line 10
PHP Fatal error: Function name must be a string in /home/edwin/hola.php on line 10
これは機能します!ありがとう!この現象の背景情報はありますか? –