Object and Class in PHP

Object and class in php - The basic part of an object-oriented program is the objects. We can easily understand this object. For example, a car is an object. A car has properties or parts inside, such as colors, engines, wheels, doors and so on. A car can also do something (there is something that can be done with a car), such as filling up gasoline, turning on the engine, walking, braking and so on.
Object and Class in PHP

Usually the object is a noun. People are objects. Likewise cars, trees, flowers, computers, TV, books and so on. However, objects are not always a physical object. It could be an abstract object, such as a bank account, a file on a computer, a database, an email message, a TV show, and so on.
Class is an explanation or description of the object. Inside the class, there is an explanation of an object including its properties and behavior or methods that can be done by the object. For example, the Person class. Class People certainly have at least some parts such as hands, feet, eyes, ears and so on. Class People also must at least be able to walk, can jump, can run, can see, can talk and so forth.
One of the advantages of the program is defined by the concept of object-oriented programming is the encapsulation of the program in the class and object, where the programmer who uses the class does not need to know the contents and the way the class in detail, just need to know how to use it. Same with a car for example. A car owner certainly does not need to know the car parts thoroughly. He does not need to know how a car engine burns and how a car's engine can move a wheel, and so on. He just needs to know how to run the car, how to stop the car, and other car functions.
The general form defines a class as follows:
class Classname
{
Declare and define properties here
Define all methods here
}

Forming Class Objects
To use an object, an object must be formed of its class. From a class can be formed several objects at once. The general form of object formation is as follows:
$Objectname = new Classname();
As for calling members (members) of the class can with the format as follows:
$Objectname -> variabel;
$Objectname -> namaMethod();

That's my article about object and class in php. Hopefully the artist can provide benefits and increase your knowledge about the php programming language.

Comments