<?php
class Mobile {
public $deviceName,$deviceVersion,$deviceColor;
public function __construct ($name,$version,$color) {
$this->deviceName = $name;
$this->deviceVersion = $version;
$this->deviceColor = $color;
echo "The ".__CLASS__." class is stratup.<br /><br />";
}
public function printOut () {
echo 'I have a '.$this->deviceName
.' version '.$this->deviceVersion
.' my device color is : '.$this->deviceColor;
}
public function __destruct () {
$this->deviceName = 'Removed';
echo '<br /><br />Dumpping Mobile::deviceName to make sure its removed, Olay :';
var_dump($this->deviceName);
echo "<br />The ".__CLASS__." class is shutdown.";
}
}
$mob = new Mobile('iPhone','5','Black');
$mob->printOut();
?>
The Mobile class is stratup.
I have a iPhone version 5 my device color is : Black
Dumpping Mobile::deviceName to make sure its removed, Olay
string 'Removed' (length=7)
The Mobile class is shutdown.