To create instance of a class, a new keyword must be used. An object will always be created unless the object has a constructor. It throws an exception on error. Classes should be defined before instantiation (and in some cases this is a requirement).
If a string contains the name of a class is used with new, a new instance of that class will be created. If the class is in a namespace, its fully qualified name must be used when doing this.
<?php $instance = new Slightbook(); // This can also be done with a variable: $className1 = 'Slightbook'; $instance = new $className1(); // new Slightbook() ?>
In a class context, it is possible to create a new object by new self and new parent.
When assigning an already created instance of a class to a new variable, the new variable will access the same instance as the object which was assigned. This behaviour is the same when passing instances to a function. A copy of already created object can be made by cloning it.