PHP coding issue: this won't display name

net*_*rox 0 php oop

I am puzzled why it won't display the name. I expect to see the output, "Jeffrey" but it doesn't. I created an object with an argument to be passed to the constructor so I expected "JEFFREY" to be displayed but it didn't. I added the echo function in constructor to see if it output jeffrey and it didn't echo either. PHP didn't show any errors. What is that I am doing wrong?

class person {

 public $name;

 function __constructor($name)
 {
  $this->name=strtoupper($name); 
  echo $name;
  }

   function displayName()
  {
   echo "<h1>$this->name</h1>";  
   }

 }

 $m = new person("jeffrey");
 $m->displayName();
Run Code Online (Sandbox Code Playgroud)

Pek*_*ica 6

您有一个语法错误:必须命名构造函数__construct(),而不是__constructor().

永远不会调用您的构造函数,$this->name也不会保存.