Object inheritance
The OOP paradigm places objects at the heart of application design, where objects can be looked at as units that contain various properties and methods. Interaction between these properties and methods defines the internal state of an object. Every object is built from a blueprint called a class. There is no such thing as an object without the class, at least not in a class-based OOP.
Note
We differentiate class-based OOP (PHP, Java, C#, ...) and prototype-based OOP (ECMAScript / JavaScript, Lua, ...). In class-based OOP, objects are created from classes; in prototype-based OOP, objects are created from other objects.
The process of building or creating new objects is called instantiation. In PHP, like many other languages, we use the new
keyword to instantiate an object from a given class. Let's take a look at the following example:
<?php class JsonOutput { protected $content; public function setContent($content) { $this->content = $content; } public...