<html>
<body>
class Fruit {
public $name;
public $color;
function __construct($name) {
$this->name = $name;
}
function get_name() {
return $this->name;
}
}
$apple = new Fruit("Apple");
echo $apple->get_name();
</body>
<!-- Mirrored from www.w3schools.com/php/phptryit.asp?filename=tryphp_constructor by HTTrack Website Copier/3.x [XR&CO'2014], Wed, 21 Dec 2022 16:49:39 GMT -->
</html>