April 2026
Intermediate
1009 pages
34h 15m
English
You now know the basics of object orientation. Now it's time to get down to the finer details. This includes certain methods, but also interfaces and abstract classes.
PHP passes objects as references. This was originally different in PHP 4, where objects were treated as values.
You can find a test example in the materials for the book (see Preface). It is called objects_values.php.
But how can we pass an object as a value to a function? To do this, you need to clone the object. The clone keyword is used for this. In this case, a copy of the original instance is created and passed to the function. You can see the result in Figure 11.11.
<?php class Computer { public $CPU = "The CPU"; public function ...
Read now
Unlock full access