Skip to content

Category: Programming

Benchmarking PHP: Inserting text with include(), require(), or get_file_contents()

Often times in PHP you find yourself needing to insert text. Most sites do this by using a database backend, but you also have the option to include data from a text file. Three methods are available for this; require, include, and file_get_contents. Which is fastest, which is best? When should you use one over the other?

StatTraq and WordPress Permalinks

For this and my other blog, I use WordPress with permalinks turned on. I installed an add-in called StatTraq to keep track of statistics. But, the stats page never showed which pages were being shown. It just showed that ‘Multiple Posts’ were being displayed. Honestly, I just assumed this was the way StatTraq was supposed to work until I just happened to get hit by a comment spammer.

Script timing in PHP

It you have spent time on sites that use a CMS system as a back-end, you may have noticed a line towards the bottom that tells you how long that page took to generate. While not always useful for the end user, it is very useful to you as a the developer. It gives you a quanitative look at how quickly your pages are being generated, and you can use this to determine if your code or queries need to be modified to work more quickly or if your server is overloaded.