<?php
class person {
public $isAlive = true;
public $firstname;
public $lastname;
public $age;
public function __construct($firstname, $lastname, $age) {
$this -> firstname = $firstname;
$this -> lastname = $lastname;
$this -> age = $age;
}
public function greet() {
echo "Hello, my name is " . $this->firstname . " " . $this -> lastname . ". Nice to meet you! :-)";
}
}
$teacher = new person("boring", "12345", 12345);
$student = new person("Chandler", "Smith", 33);
echo $teacher -> greet();
<br>
echo $student -> greet();
</br>
?>
- Output for 7.0.0
- Parse error: syntax error, unexpected '<', expecting end of file in /in/Y1sm1 on line 24
Process exited with code 255. - Output for 5.5.24 - 5.5.30, 5.6.8 - 5.6.16
- Parse error: syntax error, unexpected '<' in /in/Y1sm1 on line 24
Process exited with code 255.
preferences:
166.77 ms | 1395 KiB | 24 Q