Echo Return construct method;

后端 未结 6 1743
有刺的猬
有刺的猬 2021-01-25 08:11

6条回答
  •  孤独总比滥情好
    2021-01-25 08:42

    You could use the __toString magic method to get __construct to echo out or you could just getmetod without using __toString magic method. There are many ways just pick one of them.

    foo = $foo;
        }
    
        public function __toString()
        {
            return $this->foo;
        }
    }
    
    $class = new TestClass('Hello');
    echo $class;
    ?>
    

    __toString()

提交回复
热议问题