Category: PHP Tutorial

python tutorials and learn python

Created with Sketch.

How to Call the Parent Constructor

How to Call the Parent Constructor Summary: in this tutorial, you’ll learn how to call the parent constructor from the constructor of the child class. Child class doesn’t have a constructor In the inheritance tutorial, you have learned how to define the SavingAccount class that inherits the BankAccount class: However, we haven’t discussed the constructors…
Read more

PHP Inheritance

PHP Inheritance Summary: in this tutorial, you will learn about the PHP inheritance that allows a class to reuse the code from another class. Introduction to the PHP inheritance Inheritance allows a class to reuse the code from another class without duplicating it. In inheritance, you have a parent class with properties and methods, and…
Read more

PHP Readonly Properties

PHP Readonly Properties Summary: in this tutorial, you’ll learn about the PHP readonly properties that can be only initialized once. Introduction to the PHP readonly properties PHP 8.1 introduced the readonly class properties. The readonly properties allow you to define properties that can be only initialized once within the class. To define a readonly property,…
Read more

PHP Typed Properties

PHP Typed Properties Summary: in this tutorial, you wil learn how to define typed properties by adding type hints to class properties. Introduction to the PHP typed properties The following example defines the BankAccount class with a property called $balance: class BankAccount { public $balance; } Code language: PHP (php) The default value of the…
Read more

PHP Destructor

PHP Destructor Summary: in this tutorial, you will learn about the PHP destructor and use it to clean up the resources when the object is deleted. Introduction to the PHP destructor Like the constructor, PHP allows you to define a destructor for a class using a special method __destruct() like this: <?php class className {…
Read more

PHP Constructor

PHP Constructor Summary: in this tutorial, you will learn how to use the PHP constructor to initialize the properties of an object. Introduction to the PHP Constructor PHP allows you to declare a constructor method for a class with the name __construct() as follows: <?php class ClassName { function __construct() { // implementation } }…
Read more

PHP Access Modifiers

PHP Access Modifiers Summary: in this tutorial, you will learn about PHP access modifiers, including public and private, and understand the differences between them. Introduction to PHP access modifiers In the objects and classes tutorial, you have learned about how to use the public access modifier with properties and methods. In fact, PHP has three…
Read more

PHP $this

PHP $this Summary: in this tutorial, you will learn about PHP $this keyword and how to use $this inside a class to reference the current object. What is $this in PHP? In PHP, $this keyword references the current object of the class. The $this keyword allows you to access the properties and methods of the…
Read more

PHP Objects

PHP Objects Summary: in this tutorial, you will learn about PHP objects, how to define a class, and how to create an object from a class. What is an Object If you look at the world around you, you’ll find many examples of tangible objects: lamps, phones, computers, and cars. Also, you can find intangible…
Read more

PHP OOP

PHP OOP This PHP OOP series helps you master Object-oriented Programming in PHP. PHP introduced object-oriented programming features since version 5.0. Object-Oriented programming is one of the most popular programming paradigms based on the concept of objects and classes. PHP OOP allows you to structure a complex application into a simpler and more maintainable structure.…
Read more