Final Keyword in PHP class

PHP 5 introduces the final keyword. It prevents child classes from overriding a method by prefixing the definition with final. If the class itself is being defined final then it cannot be extended.

Final methods example
<?php

class BaseClass {
public function test() {
echo “BaseClass::test() called\n”;
}

final public

Read more

Object Cloning in PHP

Creating a copy of an object with fully replicated properties is not always the wanted behavior.

An object copy is created by using the clone keyword (which calls the object’s __clone() method if possible). An object’s __clone() method cannot be called directly.

$copy_of_object = clone $object;

When an object is … Read more