• 1902 0

    Exception handling is an elegant way to handle errors which are beyond the program’s scope. For example, if our application fails to contact the database, we use exception handling to contact another data source or to provide instructions to the users that...

  • PHP allows a class to inherit from only a single parent class, but sometimes we cannot escape the necessity to use code from more than one resource. In these cases, it is common to chain more and more parents. However, this can...

  • In certain cases, we might want to approach methods and properties of a class without the need to first create an object out of the class. This can be achieved by defining the methods and properties of a class as static. Even...

  • Type hinting forces our functions and methods to get only arguments that belong to a specific class, a specific interface, or to arrays. This practice can be most advantageous because it results in better code organization and improved error messages. This tutorial explains type hinting...

  • In this tutorial, we are going to learn a naming convention that can help us write code which is much more coherent and easy to use. According to the Polymorphism (Greek for “many forms”) principle, methods in different classes that do similar...

  • Interfaces resemble abstract classes in that they include abstract methods that the programmer must define in the classes that inherit from the interface. In this way, interfaces contribute to code organization because they commit the child classes to the methods that...

  • We use abstract classes and methods when we need to commit the child classes to certain methods that they inherit from the parent class but we cannot commit about the code that should be written inside the methods. An abstract class is a...

  • PHP does not support multiple inheritance. PHP supports multileve inheritance. Child class class can't inherit by more than one parent class. But Parent class inherit the properties of prand parend class and grand child can inherit the properties of parent class.  Multiple inheritance in PHP This...

  • One of the main advantages of object-oriented programming is the ability to reduce code duplication with inheritance. Code duplication occurs when a programmer writes the same code more than once, a problem that inheritance strives to solve. In inheritance, we have a parent class with...

  • The names of magic methods always start with two underscores, and the __construct() magic method is no exception. We use __construct() in order to do something as soon as we create an object out of a class. A method of this kind is called...

Subscribe For Latest Updates

Enter your email address to subscribe to this blog and receive notifications of new posts by email.