开发者

Call to undefined function handler

Is it possible to handle this type of errors? Something like spl_autoload_register, but for functions.

Basically, what I am trying to do:

I have the class:

class Foo {
   public function bar() {
     echo 1;
   } 
}

So, when I call a nonexistent function开发者_开发技巧 Foo() like this:

Foo()->bar();

The possible handler should create a function Foo(), which looks like that:

function Foo() {
   return new Foo();
}


If you never need an actual instance of the object, why not use a static class?

class Foo {
   public static function bar() {
     echo 1;
   } 
}

Foo::bar();

Then, you can do this in your app:

$this->fiends = FriendsModel::getUserFriends($userId);
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜