Trusted SSL from just $3.44


Namespaces in PHP


What are namespaces in PHP? Namespaces in PHP are also described as qualifiers that provide two main functions to the program. Using namesapce organize the code by grouping the classes of same nature into a single namespace.Namespace allows us to use same name for more than one class because they are wraped in the namespace. General Example of Namespaces For instance, we have a group of classes...

Static Properties in PHP OOP


Static keyword in PHP What are static properties in PHP? Just like we studied static methods in the previous tutorial, static properties in PHP are accessible within and outside the class directly. The static keyword is used to define the static properties of a class. To access the static properties of a class, we use the scope resolution operator :: <?php class Example { public static...

Static methods in PHP OOP


In this tutorial we will learn more about the static methods in PHP OOP. We will discuss what static methods are meant for, when to use them, the syntax and the difference between static and non-static methods. What are static methods in PHP? Static methods are created using static keyword.Static methods of a class are called directly. It means, we don’t need to create the instance of the...

Traits in PHP


In this article, you will learn traits in PHP. PHP – What are Traits? In PHP, you can inherit from only one parent class. Traits overcome this limitation of PHP and allow you to inherit multiple behaviors. A trait is a class that contains both abstract and non-abstract methods. Different classes can use these methods in their own way. The trait methods can be public, private, or protected...

Interface in PHP


In this tutorial, we will learn the interface in PHP. What is an interface in OOP? An interface is a class that contains only abstract methods. By using the interface class, we can specify which methods a class should implement that extend the interface. Unlike abstract class, you don’t need to write abstracts with the methods because an interface can only have abstract methods in it...

Abstract Class in PHP OOP


In this article, we will learn abstract class in PHP. What is an abstract class in PHP? An abstract class contains the declaration of methods but not their definition. It only contains their names. It is the responsibility of the child class to define these methods. What is an abstract method? An abstract method is a method of an abstract class that is declared using abstract keywords and does...

Constants in PHP OOP


In this article, we will learn constants in PHP. What are constants in PHP? Constants are used to store some value that remains unchanged during the execution of the program. We can declare constant using constant keyword followed by the name of the constant. The name of constant is case-sensitive, however, it is recommended in PHP to name the constant in upper-case letters. Constants in PHP How...

Inheritance in PHP OOP


What is Inheritance? When a class derives from another class, it is known as inheritance. Here are some important terms related to inheritance in PHP. Parent Class – The class from which the other classes are derived is called parent class. It is also known as base class.Child Class – The class that is derived from another class is called child class. There are some other names for it...

Access Modifiers in PHP


Like other languages, PHP also implements some scope for the methods or attributes of the class. Access modifiers define where the class variables or methods can be accessed. In this article, you will learn about the access modifiers in PHP OOP and their types. Types of Access Modifiers in PHP There are three access modifiers in PHP. Public – When you create a method or attribute in the PHP...

Constructor and Destructor in PHP


In the previous article, we have covered the basic concepts of a class and objects. In this PHP tutorial, you will learn constructor and destructor in the PHP class. What is a Constructor and Destructor in PHP class? Constructor As the name suggests, a construct constructs an object. The real definition of a constructor is, it initializes the object of the class. How to declare the constructor in...

Tutor Network

Learn PHP from A to Z