PHP & OOP: Properties of a class

This entry is part 6 of 11 in the series PHP & OOP

Class member variables are called ‘properties‘.

When I first started learning OOP using C++, I thought this is odd.  It sounds abstract.

But look at the following declarations for the 2 class members and you might be able to understand.


class MovieStar
    public $person = 'Tom Cruise';
    public $salary = 10000;
    public $movie = 'Mission Impossible';
    public $no_of_movies = 20;

class PopStar
    public $person = 'Madonna';
    public $salary = 8000;
    public $album = 'Crazy For You';
    public $no_of_album = 12;


From the class properties such as $movie and $album, we could guess what the 2 classes are about.

Series Navigation<< PHP & OOP: $this variable
PHP & OOP: Methods of a class >>

Leave a comment

Leave a Reply