PHP Tricks
Short tutorials on how to add useful enhancements to your website with some PHP code, and snippets of code I found interesting.

A one liner that you can append to the code of your website's footer to avoid the need of manually updating the year every year (includes JavaScript alternative solution for static html pages).

Once in a while you might realize that you wish your code snippet which uses many echo statements had saved the output into a variable, instead of displaying it; it's when output buffering comes to rescue.

When you have a need to check for multiple possible values in a single variable, often the switch conditional is a preferred alternative to a long if ((...) || (...) || (...) ...) conditional expression.

The article demonstrates how to validate email, URL, integer, and decimal number and includes a snippet of code that would be used in a production script.

In this tutorial I show how to filter the existing page related content to generate and fill the following html tags:
<title>...</title>
<meta name="description" content="...">
<meta name="description" content="...">

In this, step by step guidance, you'll see how a few adjustments to the original code that goes with the venerable book by Cristian Darie and Emilian Balanescu, published in 2008 will bring the shop to life with a much newer version of PHP and MySQL.

Here I'll show you how to utilize the spl_autoload_register() function from the Standard PHP Library (SPL) that helps to avoid manually including files that contain object oriented class definitions.

In this tutorial I'll show you how to use a function that calls itself to scan a directory tree and output its contents.
Using a Recursive Function to Traverse a Directory Tree - Part 2
This is a more flexible version of the previous script, now the name of a directory can be specified through an html form, and there are thumbnails for images that get found along the way.
This is a more flexible version of the previous script, now the name of a directory can be specified through an html form, and there are thumbnails for images that get found along the way.
This page was last updated on March 02, 2021