Home  >  Q&A  >  body text

Regarding the issue of whether subclasses will automatically call the parent class constructor

<?php

header("content-type:text/html;charset=utf-8");

class nn//This code is obvious. The class automatically calls the constructor of the parent class. . . .

{

public $name;

public function __construct()

{

echo 'I am in the nn class Constructor! <br>';

//$this->name=$iname;

}


}

class mm extends nn

{


}

$p=new mm;

?> ;


帝释天帝释天2029 days ago946

reply all(0)I'll reply

No reply
  • Cancelreply