<html>
<body>
class Fruit {
public $name;
public $color;
function __construct($name, $color) {
$this->name = $name;
$this->color = $color;
}
function get_name() {
return $this->name;
}
function get_color() {
return $this->color;
}
}
$apple = new Fruit("Apple", "red");
echo $apple->get_name();
echo "<br>";
echo $apple->get_color();
</body>
<!-- Mirrored from www.w3schools.com/php/phptryit.asp?filename=tryphp_constructor2 by HTTrack Website Copier/3.x [XR&CO'2014], Mon, 27 Jan 2020 02:50:49 GMT -->
</html>