How to Use assert() in PHP

* { box-sizing: border-box; } body {margin: 0;}*{box-sizing:border-box;}body{margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px;} In this article, I’ll teach you about the assert() function in PHP. I will teach you what exactly it is, how it works, and the right context to use it in your code. Along the way, I’ll use simple example code snippets that will help you to… Continue reading How to Use assert() in PHP

Add Days to a Date With PHP DateInterval

* { box-sizing: border-box; } body {margin: 0;}*{box-sizing:border-box;}body{margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px;} PHP has a lot of methods and functions to help you manipulate dates in a variety of ways. In this quick tip, I will show you how to add days to a date in PHP using the DateInterval class. We will begin with an overview of DateInterval… Continue reading Add Days to a Date With PHP DateInterval

Pop and Shift Arrays With PHP: When to Use Each One

* { box-sizing: border-box; } body {margin: 0;}*{box-sizing:border-box;}body{margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px;} PHP has a lot of built-in array functions to help with many common tasks. The presence of so many functions, though, can also be a bit overwhelming because sometimes you have to keep the slight differences between these functions in mind. It is also possible to use… Continue reading Pop and Shift Arrays With PHP: When to Use Each One

Read a CSV to Array in PHP

* { box-sizing: border-box; } body {margin: 0;}*{box-sizing:border-box;}body{margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px;} In this post, I’ll show you how to use PHP’s built-in functions to read and print the contents of a CSV file and convert it into an array. We’ll use fopen() and fgetcsv() to read the contents of a CSV file, then we’ll convert it into an… Continue reading Read a CSV to Array in PHP

PHP Type Casting: A Complete Guide

* { box-sizing: border-box; } body {margin: 0;}*{box-sizing:border-box;}body{margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px;} When you are writing a program, you will need to create and manipulate multiple variables. These variables might store the same or different types of data. For example, some of them could have an integer value while others could be a string or float. Different programming languages… Continue reading PHP Type Casting: A Complete Guide

Functional Programming in PHP With Lambda Functions

* { box-sizing: border-box; } body {margin: 0;}*{box-sizing:border-box;}body{margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px;} One of the nice things about programming is that the same problem can be solved using multiple methods. This allows people to show their creativity and come up with incredibly efficient and unique solutions. Examples of this can be seen in action when you look for programs… Continue reading Functional Programming in PHP With Lambda Functions

Understanding Static Functions and Static Classes in PHP

* { box-sizing: border-box; } body {margin: 0;}*{box-sizing:border-box;}body{margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px;} Static functions and static classes can be easily accessed without necessarily creating an instance of that class. This helps keep your code clean and organized. In this post, you’ll learn about the static keyword and how it is applied on functions and classes to make them static.… Continue reading Understanding Static Functions and Static Classes in PHP

How to Use parse_str in PHP

In this article, we’ll explore the parse_str function in PHP. It’s used to convert a GET request query string into usable variables. In your day-to-day PHP development, you often need to to deal with query strings—the way data is passed to your script in the URL on a GET request. When a query string is… Continue reading How to Use parse_str in PHP

How to Use parse_str in PHP

In this article, we’ll explore the parse_str function in PHP. It’s used to convert a GET request query string into usable variables. In your day-to-day PHP development, you often need to to deal with query strings—the way data is passed to your script in the URL on a GET request. When a query string is… Continue reading How to Use parse_str in PHP

How to Append to a File With PHP

Data is usually stored in a database when people are creating their website. However, sometimes we need to store data in files to make it easier for people to read or modify at a later time. PHP comes with a lot of functions to read and write data to a file. We can also use… Continue reading How to Append to a File With PHP

How to Check if a File Exists in PHP

Many times you will either need to move files around or store some data inside them in PHP. In either case, knowing beforehand whether a file exists or not can help us avoid some unexpected behavior. PHP comes with a variety of functions to handle different types of queries related to files. In this tutorial,… Continue reading How to Check if a File Exists in PHP

What Is JavaScript?

Technology is advancing rapidly and web development is no different. New tools and services are constantly coming into existence to help you build the next big thing. It’s great to have so much innovation in web development, but it can be very intimidating for people who are just starting out in the field and have… Continue reading What Is JavaScript?

How to Compare Dates in PHP

Comparing dates becomes necessary when you are creating booking and event scheduling plugins or websites in PHP. It has many other uses as well, depending on how you implement things. For example, we might use it to create time-sensitive promotional events in our PHP scripts. PHP comes with dedicated functions and methods that you can… Continue reading How to Compare Dates in PHP

Using the PHP Switch Statement

In this article, we’ll discuss the basics of the switch statement in PHP. Along with the syntax of the switch statement, we’ll also go through a couple of real-world examples to demonstrate how you can use it. What Is the Use of the Switch Statement? In PHP, the switch statement is considered as an alternative… Continue reading Using the PHP Switch Statement

Understanding PHP Constructors

In this article, we’re going to discuss the basics of constructors in PHP. You’ll learn the purpose of PHP constructors and how to use them. What Is a Constructor? Here’s the official definition: Constructors are ordinary methods which are called during the instantiation of their corresponding object. As such, they may define an arbitrary number… Continue reading Understanding PHP Constructors

How to Parse JSON in PHP

JSON, short for JavaScript Object Notation, is a common lightweight format for storing and exchanging information. As the name suggests, it was initially derived from JavaScript but it is a language-independent format for storing information. A lot of languages like PHP now implement functions to read and create JSON data. This tutorial will teach you… Continue reading How to Parse JSON in PHP

PHP round, ceil, and floor: Which One to Use?

A lot of programs, both big and small, require us to deal with numbers. There are two ways of defining numbers in PHP. They can either be floats or integers. We can also use strings to represent very large numbers. You can learn more about these data types and converting between them in this tutorial… Continue reading PHP round, ceil, and floor: Which One to Use?

Which Back-End to Choose? Node.js vs PHP

In this article, we’re going to discuss PHP and Node.js: two popular back-end technologies for web applications. We’ll discuss the key differences between them to help you choose the right back-end technology for your next project. Introduction First of all, let’s go through what exactly these two back-end technologies are and what they are used… Continue reading Which Back-End to Choose? Node.js vs PHP

How to Increase max_execution_time in PHP

In this quick article, we’ll explore the different options that allow you to increase the maximum amount of time a script is allowed to run before it’s terminated by a the parser in PHP. What is the max_execution_time Directive in PHP? The max_execution_time directive sets the maximum amount of time a script is allowed to… Continue reading How to Increase max_execution_time in PHP

Anonymous and Arrow Functions in PHP

I’ve already covered the basics of functions in PHP in one of a previous tutorials. Even though PHP has a lot of built-in functions, it gives us the choice to define our own functions as well. There are different ways to define our own functions in PHP. PHP Functions in PHP: Return Values and Parameters… Continue reading Anonymous and Arrow Functions in PHP

How to Work With Regular Expressions in PHP

In this article, we’ll go through the PHP functions that allow you to use regular expressions to perform search and replace operations on strings. What Is a Regular Expression? Regular expressions—also called “regex”—are search patterns for text. These patterns can be processed by a regex engine to find substrings, validate that a string matches a… Continue reading How to Work With Regular Expressions in PHP

What is PHP Used For?

PHP is an open source language that was created to make web development easier. It’s primary and most suitable purpose is as a web development language for creating web apps or APIs. You don’t need a complicated set of commands to create webpages in PHP. In fact, you can mix PHP with plain HTML in… Continue reading What is PHP Used For?