PHP Get Returned Value From Constructor

后端 未结 1 1534
耶瑟儿~
耶瑟儿~ 2020-12-07 06:48

I am confused, I have a PHP class with a constructor:

class Test {
   public function __construct() {
      return \"some text\";
   }
}

Th

相关标签:
1条回答
  • 2020-12-07 07:21

    You cannot return anything from a constructor. The new keyword will always result in a new object, it does not matter what you return from the constructor.

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