PHP Basics

Total lessons: 25

PHP 7.4 New Features

PHP 7.4 comes with a few new features that can help improve performance and make for cleaner code. Here's some of the new features that come with PHP 7.4.

Shorthand Comparisons In PHP

In this tutorial we're going to investigate how we can improve our code by cleaning up unnecessary code by using shorthand code samples in PHP. So what do I mean by removing unnecessary code? The most...

PHP7 Array Iteration Trick

In this tutorial we're going to look into a look tip for dealing with PHP array iterations with PHP 7. When you're developing in PHP and need to iterate over an array you'll probably see something lik...

Increment Numeric Part Of String

Have you ever needed to increment the number which is part of a string. For example if you have an invoice number with the format und001 and want to be able to automatically create the next invoice nu...

Return Class Constant From Variable

PHP constant values allow you to set a variable on the class which will remain the same and is unchangeable. The difference between these constants and other variables in a class is that they are not...

Sort Multi-Dimensional Array By Value In PHP

The following code snippet will help to sort multi-dimensional arrays by a value of one of the elements. If you look at the code below we have an array populated with 3 other arrays, each of them has...

Learn How To Use DateTime With PHP

In version 5.2 of PHP the DateTime class was introduced, in this tutorial we are going to investigate how the DateTime class can be used and why it's better to use this class over the old date() and t...

PHP Template Engines

A PHP template engine is a way of outputting PHP in your HTML, without using PHP syntax or PHP tags. It's suppose to be used by having a PHP class that will send your HTML the variables you want to di...

Register Your Own Autoload Functions

PHP has a few in-built magic method __get(), __set(), __sleep(), __toString() etc. These functions are all really useful but they are not used very often in your day-to-day development, but one magic...

Remove Characters At Start And End Of A String In PHP

In a previous article about how you can remove whitesapce from a string I spoke about using the functions ltrim() and rtrim(). These work by passing in a string and they will remove the whitespace. Us...

Hash Passwords With PHP 5.5

Almost every PHP developer would have to build an application that relies on a user login. This will involve the user of the website having a Username and Password which is stored in the database so t...

How To Compare Strings In PHP

During any sort of programming you will always get situations where you need to compare values with each other, if the values are boolean or integers then the comparison is simple. But if you want to...

Automatically Detect Browser Language With PHP

When you are working on a multi national website you may need the functionality to translate your website into different languages. There are many ways you can translate a website, in this article I w...

Formatted Strings With PHP

When you are using PHP to putput a string on the page most of the time you will use the syntax echo, which will take the following string and display that string in HTML. You can even concaternate mul...

Namespaces With PHP

PHP namespaces was introduced in version 5.3. Namespaces is a way of group classes together into virtual directories, the main reason we would want to do this is to help avoid collision of class names...