PHP

   »    Free PHP book resources & Tutorials

Computer Education, Training & Tutorial Resources - ComputerEducationWorld.com
Home » Free Computer Books » PHP »

3.6.2 public, protected, and private Methods
Access modifiers may also be used in conjunction with object methods, and the
rules are the same:
public methods can be called from any scope.
protected methods can only be called from within one of its class methods
or from within an inheriting class. private methods can only be called from within one of its class methods
and not from an inheriting class. (more…)


• • •
 

3.6.1 public, protected, and private Properties
A key paradigm in OOP is encapsulation and access protection of object prop-
erties (also referred to as member variables). Most common OO languages
have three main access restriction keywords: public, protected, and private.
When defining a class member in the class definition, the developer
needs to specify one of these three access modifiers before declaring the mem-
ber itself. (more…)


• • •
 

3.6 ACCESSING METHODS AND PROPERTIES USING THE $this
VARIABLE

During the execution of an object’s method, a special variable called $this is
automatically defined, which denotes a reference to the object itself. By using
this variable and the -> notation, the object’s methods and properties can be
further referenced. For example, you can access the $name property by using
$this->name (note that you don’t use a $ before the name of the property). An
object’s methods can be accessed in the same way; for example, from inside one
of person’s methods, you could call getName() by writing $this->getName().


• • •
 

3.5 DESTRUCTORS
Destructor functions
are the opposite of constructors. They are called when
the object is being destroyed (for example, when there are no more references
to the object). As PHP makes sure all resources are freed at the end of each
request, the importance of destructors is limited. However, they can still be
useful for performing certain actions, such as flushing a resource or logging
information on object destruction. (more…)


• • •
 



captcha PHP Script Free PHP captcha script free php
Website Design by WebWalas.com