March 2008
Intermediate to advanced
458 pages
11h 25m
English
The public, protected, and private keywords describe what kind of access restriction is in place for an object’s attributes and methods. Public is the least restrictive and means that any other object or code can gain direct access. This is why code can call the erase and describePencil methods in the examples in the preceding section. The class definition states that these methods are public.
For any PHP class it is possible to declare all of the attributes and methods as public. This has its advantages and disadvantages. One advantage of public attributes is that methods are not needed to access or change them, so there is less code. A major disadvantage is that since these attributes are public, they are not ...
Read now
Unlock full access