Redefining or changing a PHP $_SERVER variable for an entire website.

Today, I was faced with the need to redefine a PHP $_SERVER variable for an entire application, made up of hundreds of PHP pages. In this case, I needed to redefine $_SERVER['DOCUMENT_ROOT'] for an entire website. The application was built by another company under the assumption that $_SERVER['DOCUMENT_ROOT'] would always point to the document root, [...]


How to Detect a User’s Language with PHP

I was recently looking for a simple way to automatically detect a user’s language using PHP. There are a number of ways this could be accomplished but after some thought I realized the easiest is to get that information from the users web browser. Users are most likely to browse the web in a language [...]


How to Read a Remote Text File with PHP

Reading text files with PHP isn’t really too difficult. I have done it quite a few times but it isn’t something I do everyday. A few weeks ago, I wrote a simple script to read a text file and it has been working great, until today. Originally, the script I wrote was reading a very [...]


Software to Automatically Make a HTML version of a Dynamic Website

It seems like there are a million different content management systems out there. Some like the ZLCMS system we use at Zipline are transferrable to another web host but occasionally we have run into web development companies with ‘proprietary’ content management systems. Many of these companies won’t allow their customers to transfer their website to [...]


How to use PHP in .htm or .html Files

The need to execute PHP in HTM or HTML files may occur for a number of reasons. The most common of which seems to be adding content managed portions to an existing HTML website. The .htm or .html pages will be part of the navigation, previously indexed by search engines, and likely linked to by [...]


Block .inc Files from Displaying on an Apache Web Server

Block .inc Files from Displaying on Apache Web ServerBlock .inc Files from Displaying on Apache Web ServerMany PHP developers use the .inc file extension to signify a script that is included within another. This can be very handy when scanning a directory or block of code looking for specific references or calls. One of the [...]


How to Get the Last Four Digits of a Credit Card Number with PHP

Today, I had a friend ask me how to get the last four digits of a credit card number using PHP. I have done this at least a hundred times over the years and never really given it a second thought but for those new to PHP this could be a confusing task. It isn’t [...]


MySQL Dump of the 50 U.S. States

There have been many times I have needed a list of the 50 U.S. States for web applications. I have probably typed these in a dozen times or more over the years. It seems everytime I search for this list as a MySQL dump I am bombarded with data services trying to sell it for [...]


PHP Quick Profiler

Have you ever wanted a Firebug for PHP? Thanks to Twitter I came across the PHP Quick Profiler or PQP for short. It is a script that was developed by the team at Wufoo that helps analyze and debug performance of PHP scripts. An example of this script in use can be found at: http://particletree.com/examples/pqp/. [...]


How to get the Extension of a File Using PHP

As a PHP developer, there are times where you need to get the extension of a file. You may need to get the extension of a .jpg file so you can resize it or you may need to check to see if an uploaded file has a .pdf extension. With PHP there are a number [...]