Home  >  Q&A  >  body text

Why does Peter appear in the browser I followed the teacher's instructions but not in the teacher's browser?

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;

怪我咯怪我咯1813 days ago1307

reply all(4)I'll reply

  • 怪我咯

    怪我咯2019-11-11 19:42:23

    thanks for the reply. I later found out too.

    reply
    0
  • 邓

    2019-11-11 14:08:30

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

    reply
    0
  • 邓

    2019-11-11 13:05:00

    It seems because your constructor is public

    reply
    0
  • 邓

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

    · 2019-11-11 14:08:11
  • Cancelreply