<?php
class Person
{
Protected $name;
Protected $city;
Protected $country;
Public function __construct() {
echo "At the time of creation, this constructor is called automatically. <br />";
}
Public function print_introduction($name,$city,$country) {
$this->name = $name;
$this->city = $city;
$this->country = $country;
echo "My name is $this->name and i am from $this->city, $this->country. <br />";
}
Public function __destruct() {
echo "At last, destructor is called automatically.";
}
}
$object = new Person();
echo $object->print_introduction("Zayn","Lahore","Pakistan");
?>
At the time of creation, this constructor is called automatically. <br />My name is Zayn and i am from Lahore, Pakistan. <br />At last, destructor is called automatically.
Output for 4.4.2 - 4.4.9
Parse error: syntax error, unexpected T_STRING, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in /in/1uYXN on line 5
Process exited with code 255.
Parse error: parse error, unexpected T_STRING, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in /in/1uYXN on line 5
Process exited with code 255.
Output for 4.3.2 - 4.3.4
Parse error: parse error, expecting `T_OLD_FUNCTION' or `T_FUNCTION' or `T_VAR' or `'}'' in /in/1uYXN on line 5
Process exited with code 255.