This site is mobile accessible. Press the "Tap Here" button to use a different font-size.


Smartphone icons created by Freepik - Flaticon

PHP Constructor

Create a __construct() function

Apple

<?php
//define class Fruit
class Fruit {
  public $name;
  public $color;

  function __construct($name) {
    $this->name = $name; 
  }
  function get_name() {
    return $this->name;
  }
}

// define __construct()
$apple = new Fruit("Apple");
echo $apple->get_name();
?>