我已经定义了一个类并实例化它,之后我调用了这个类的方法,但它没有给出任何输出?

code is here: $obj is the instance of class user.I am calling methods it is not showing the output

<?php
class user{
public  $name;
public  $age;
public function _ _construct($name, $age){
    $this->name=$name;
$this->age=$age;
}
public function sayHello(){
    echo("hiiiii".$this->name."!!!");
}
public function sayAge(){
    $a=time()-strtotime($this->age);
    echo  " hello Your age is".floor($a/(365*30*60*60));
}
}

$obj = new user('xyz','16 july 1980');
$obj->sayHello();
$obj->sayAge();

?>

Just remove $var from $obj. Call it as just $obj

<?php
class user{
public  $name;
public  $age;
public function __construct($name, $age){
    $this->name=$name;
$this->age=$age;
}
public function sayHello(){
    echo("hiiiii".$this->name."!!!");
}
public function sayAge(){
    $a=time()-strtotime($this->age);
    echo  " hello Your age is".floor($a/(365*30*60*60));
}
}

$obj = new user('xyz','16 july 1980');
$obj->sayHello();
$obj->sayAge();

?>

It's because you have a syntax error on this line, and it's likely you aren't showing debugging/error messages in your PHP configuration so it looks like nothing is showing up:

var $obj = new user('xyz','16 july 1980');

"var" in front of that variable is not valid PHP syntax.

your contruct method is wrong

public function _ _construct($name, $age){
    $this->name=$name;
$this->age=$age;
}

remove the space and it should work

also remove the var from $obj