Why does Peter appear in the browser I followed the teacher's instructions but not in the teacher's browser?
怪我咯
怪我咯 2019-11-02 15:44:49
0
4
1331

Why does peter appear in the browser when I follow the teacher's instructions but not in the teacher's browser?

class Staff{ private $anme; private $age; private $salary;

public function __construct($name,$age,$salary) { $this -> name = $name ; $this -> age =$age; $this -> salary =$salary; }}

$obj =new Staff('peter',28,5000);


echo $obj ->name;

怪我咯
怪我咯

reply all(3)
胡胡

thanks for the reply. I later found out too.

邓

Help you find the reason. Your first variable is declared as $anme, and the output is name

邓

It seems because your constructor is public

  • reply Help you find the reason. Your first variable is declared as $anme, and the output is name.
    author 2019-11-11 14:08:11
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template