In general object oriented model (OOM) allows better parsing (or compiling) performance and more features.
In PHP, once an object is created, a variable makes a reference to that object; meaning that it contains a reference to it instead of copying an entire object every time it is being used.
Classes and their creation
In PHP objects are called classes. A class begins with the syntax word class
followed by curly brackets. Within these brackets, properties and methods belong to this class are defined. Constants and variables inside the class are known as properties of the class. While functions inside the class are known as methods.
Syntax of a class
<?php
class myClass
{
public $var = 'initial value here...'; // a property
public function classMethod () // a method
{
// method's code here...
}
}
?>
Comments
No comments have been made yet.
Please login to leave a comment. Login now