Example #1
0
// $object->age = 20; compile error
$object->name = "Beibin";
// note: we do not need the dollar sign for member variable!!!
$object->password = "******";
$object->save_user();
print_r($object);
// objects in PHP are like pointers
$another_object = $object;
$another_object->name = "Baby";
print "<br>";
print_r($object);
// now, the original object is also changed.
User::counting();
// :: is the way to call static function in class
$object2 = new User("Lord", "10rd iS a G0d");
User::counting();
print "<br><br>";
//////////////////// SUBCLASS ////////////////////
class Subscriber extends User
{
    public $phone = 9000001234;
    public $email = "*****@*****.**";
    function __construct($name_, $pass_, $phone_, $email_)
    {
        User::__construct($name_, $pass_);
        // call parent constructor
        // We will not default call it
        $this->phone = $phone_;
        $this->email = $email_;
    }
    function display()