PHP OOP-Class Constants

Constants are bits of data saved in the computer’s memory that can not be modified once they have been assigned. Constants declared within classes are known as class constants. Declaring Class Constants A class constant is declared with the const keyword. Class constant must be declared inside class. Note: Class constants are case-sensitive. It is preferred that … Read more

PHP OOP – Inheritance

When a class descends from another class in Object-Oriented Programming, this is referred to as inheritance. The derived class is known as child/subclass. The class from which the child class is derived is known as the super/parent class. The parent class’s public and protected properties and methods are passed down to the child class. A … Read more

PHP OOP-Final Keyword

In PHP, we can’t declare variables as Final. Only classes and class methods are allowed to use the Final keyword. If we define a class method as Final, the child class will not be able to override that method of the parent class. Similarly to methods, declaring a class as Final prevents it from being expanded.

PHP OOP – Abstract Class

A class with at least one abstract method is called an abstract class. Names and arguments are the only things that abstract methods can have; no other code is allowed. As a result, we can’t make objects from abstract classes. Instead, we must build child classes that include the code in the method body, and … Read more

PHP Cookie

A PHP cookie is a tiny file that the web server saves on the client computer, with a maximum size of 4KB. The cookie will be sent each time the same computer requests a page through a browser. They are often used to store track of information like a username that the site can use to … Read more

PHP Session

A session is a frame of communication between two mediums. PHP sessions are used to temporarily store and transmit information from one page to another (until the user close the website). Problem:  The HTTP address does not keep state, So the web server has no idea who you are or what you do. Solution: Session variables … Read more

PHP Include and Require

In this chapter we will study PHP include and require functions: Problem: As we all know, PHP allows us to develop a variety of functions and elements that can be reused across multiple pages. Scripting the same function across numerous pages takes a lot of time and work. Solution: File inclusion is the solution. It … Read more

PHP Date and Time

Whenever conducting SQL queries or constructing a website PHP date and time are two of the most commonly used functions in PHP. For these purposes, PHP provides predefined functions. The following sections go over some of PHP’s built-in date and time capabilities. PHP date() Function A timestamp is converted to a more readable date and … Read more

PHP Exception Handling

PHP  Exception handling is nearly identical to that of other programming languages. Before moving ahead let’s see what exception is: For exception handling, PHP supports the following keywords. Keywords Description try It specifies a piece of code where an exception may occur. catch It specifies a piece of code that will be executed in case … Read more

PHP File Handling

PHP File handling is necessary for any web application. For particular tasks, you will frequently need to open and process a file. Uses of PHP File The following are some of the contexts in which we can need files in our web apps. Data is frequently saved in JSON files, and PHP code must read … Read more