PHP call static workaround for PHP 5.2

前端 未结 1 1374
北海茫月
北海茫月 2021-01-15 05:58

Is there are way to get __callStatic, or similar, functionality in PHP 5.2?

I\'m finishing a PHP Framework and need to use this functionality for a Database ORM clas

相关标签:
1条回答
  • 2021-01-15 06:34

    Not in a static capacity. Technically speaking Rails, CakePHP, etc don't call these types of dynamic methods statically. Not to get in a philosophical debate, but if backward compatibility is a requirement, you could shift your paradigm and use __call(). In which case you would call with an object like ModelObject->find_by_col2_or_col4. Of course I understand that's probably not what you wanted to hear.

    It's PHP, there's probably some kind of way to hack it, but I don't believe a native method exists.

    0 讨论(0)
提交回复
热议问题