
I use a config file in almost every PHP applications I write. Essentially I create an array called $config and setting everything I would like to be able to quickly change. For example: app name, full path to app, full url to app, development or production mode, even mysql settings....
[More]

There are a number of ways to analyze php code to get a better feel for how complex it is and clues for what it may take to work on it. For example the following linux shell command will tell you how many lines of php code there is in...
[More]

I run Ubuntu on my laptop. Every so often it is better to start over by reinstalling from scratch. I needed an easy way to keep track of what I had installed. This way when I set up the new system I can just go through the list, line by...
[More]

A number of the sites I manage run a custom CMS written from the ground up. A problem I ran into recently for one of my larger sites with over 5,500 content items is how to check if a new item might be a duplicate before its added. The solution...
[More]

There has been a number of times I wanted to store an array in a database. There was no need to split the data up and save it into individual cell. Maybe it was just debugging data or I wanted to store all the extra stuff a payment processor returns....
[More]

There are many ways in PHP to work with dates. My favorite is StrToTime, because I can store the long number (Unix Timestamp) representing the number of seconds since Jan 01, 1970 in the database. Then its easy to format it in any which way I like. Maybe one place...
[More]

This is a common problem I run it to when scrapping websites for content or even dealing with user submitted text. I ran into problems using striptags() not removing everything and general formatting errors. As a result I came up with this function to assist in the process. function clean_text($str)...
[More]

Are you having trouble testing and debugging your code? Would you like to see your php error messages in your browser? Here's how you can turn on php errors; add the following code to the top of your php script.ini_set('display_errors', 1); ini_set('display_startup_errors', 1); error_reporting(E_ALL); If you also want to see...
[More]