Chaining Static Methods in PHP?

前端 未结 16 2066
情歌与酒
情歌与酒 2020-11-27 14:25

Is it possible to chain static methods together using a static class? Say I wanted to do something like this:

$value = TestClass::toValue(5)::add(3)::subtrac         


        
16条回答
  •  攒了一身酷
    2020-11-27 14:37

    The best that can be done

    class S
    {
        public static function  __callStatic($name,$args)
        {
            echo 'called S::'.$name . '( )

    '; return '_t'; } } $_t='S'; ${${S::X()}::F()}::C();

提交回复
热议问题