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


Smartphone icons created by Freepik - Flaticon

PHP Destructor

The fruit is Apple and the color is red.

<?php
class Fruit {
  // Properties
  var $name;
  var $color;

  // Methods
  function __construct($name, $color) {
    $this->name = $name;
    $this->color = $color; 
  }
  function __destruct() {
    echo "<p>The fruit is {$this->name} and the color is {$this->color}.</p>"; 
  }
}

$apple = new Fruit("Apple", "red");
?>

The fruit is Banana and the color is yellow.