I believe the best way is to show you an example:
class Car{
private $gas=0;
private __construct(){
$gas=500; //when you create an object your gas tank is automatically filled with 500 gas for a start
}
public function fill_the_tank($amount){
$gas=$amoung;
}
public function get_gas(){
return $gas;
}
}
$ferrari = new Car;
echo $ferrari->get_gas(); //prints out "500"
$ferrari->get_gas(); //prints out nothing, but also doesn't end up in error
$ferrari->fill_the_tank(100);
echo $ferrari->get_gas() //prints out "600"
Copyright © 2026 eLLeNow.com All Rights Reserved.