Interview question: there are several ways in which a method under the constructor (non-static method) does not want to perform the construction?

topic description

A method under the constructor (non-static method) does not want to execute the constructed method

related codes

/ / Please paste the code text below (do not replace the code with pictures)

 class website extend site
 {
        public function __construct()
        {
                echo "site";
        
        }
        public function distgoods()
        {
        
        echo "123";
        
        }
 
 
 }

what does the distgoods () method do without it to execute the constructor

Apr.07,2021

inherit another one and write an empty constructor


 class website1 extends website
 {
    //
    public function __construct()
    {
    }
 }
(new website1)->distgoods();

tell you another cool techs:
directly website::distgoods (); this is also possible

  • Constructor problem

    I have a base class, Base.php, that initializes the constructor. public function __construct() { parent::__construct(); $this->authWen(); } The constructor calls a permission verification method. However, in addition to true...

    Mar.14,2021
Menu