Code Library

Mr PHP provides this code library as a way to share code snippets, tech solutions and various information that my be helpful to other coders and the programming community at large.

Regular Expression for Date or Datetime Validation

This Regular Expression will verify if a date is a valid YYYY-MM-DD with an optional HH:MM:SS. It checks to see if the day is a valid day in the given month with the consideration of leap years.

Merge Your CSS and JavaScript Using PHP

Merge all of your CSS and JS into one file to improve server speed.

Linux Processes and CPU Usage

If you want to know exactly what your server is doing right now then read on.

Although this is not PHP/MySQL related, it is still very relevant for any web developer who is managing the servers they develop on.

Useful Exim Commands

A list of a few commands useful for managing an exim mail server.

Word Permutator Function

Give this function a phrase and it will return all of the permutations of the words that make up the phrase.

MySQL Backup Script

Here is what I use to make a backup library of MySQL daily that will keep backups for 30 days.

SWFUpload with cPanel and mod_security

I searched long and hard to find what was causing swfupload to fail on my cPanel, but work on my test environment so I thought I better save the result incase I need it again.

Apache Expires Headers with mod_expires

Quick example of how to set default expires headers. This will help prevent browsers from re-downloading the same images more than once and therefore reduce the load on your image server.

2-Way MySQL Replication

Some notes and commands I want to keep handy the next time I setup MySQL replication.

Inner Resize Browser Window

This JavaScript function will resize the inside of a browser window to the dimensions provided.