Category Archives: Coding

Introduction to PHP Output Buffering

DevTips has just introduced me, in a fairly recent article, to a PHP feature that I hadn’t been conciously aware of: Output Buffering. (Why hadn’t anybody told be about this before?)

Without output buffering (the default), your HTML is sent to the browser in pieces as PHP processes through your script. With output buffering, your HTML is stored in a variable and sent to the browser as one piece at the end of your script. Can you already begin to see the performance advantages and post processing opportunities?

The article covers the basic usage output buffering, and the pros and cons of using it. Definitely worth a look. I will have to look into this in depth sometime soon…

Output Buffering for Web Developers, a Beginner’s Guide

MySQL Prepared Statements With PHP

You may already be familliar with the problem of MySQL Injection, a common exploit that can cause irreparible damage to a database. You may not be aware of it, but there is an alternative to the “mysql_*” function set. The mysqli functions, for “MySQL…

Google Canonical URLs

Finally, the solution for our duplicate content worries is over! Google now supports a new method to specify a canonical URL for your page. This “hint” suggests that Google use this page as the original, and ignore duplicates elsewhere on your domain. You simply…

PHP Serialize() Function

Arrays certainly are useful. If you’re dealing with associative data, there’s no better tool for the job. Sometimes, you’ll run into cases where it would be useful to store an entire array in a field in a database. It’s not something you want to…

PHP Str_Replace() Function

Have you ever wanted to take a string and replace every occurance of a substring with something else? Regular Expression voodoo is what first comes to mind for a lot of PHP developers. But there is an easier way that just happens to be…

PHP Tip: Prevent SQL Injection

SQL Injection is one of the most common exploits. It’s a sneaky technique that takes advantage of unsafe database querying practices to gain access to the database. Suppose you have a input form that asks for an email address for a newsletter subscription. The…

Learn Object Oriented PHP

PHP is the web programming language of choice (or scripting language, if you insist…) for many people, and my favorite as well. One thing I find interesting is when it’s taught, by many books and websites, they tend to not spend much time on…

Google AJAX Libraries API

Do you use a JavaScript library — such as jQuery, Prototype, or MooTools — on one (or more) of your websites? That probably adds a good 18-120 kilobytes to your pages’ total size, adding more time to users’ download time. Now, how many websites…

Markdown in PHP

HTML isn’t exactly easy for ordinary people to comprehend and use correctly, and allowing it’s use in web forms then entails measures to be taken to prevent malicious code from being inserted. The infamous John Gruber came up with Markdown, with the help of…

PHP Explode()

Explode() is a widely-used PHP string function that is also one that tends to mystify beginners looking at others’ code. It’s a nifty little function that you may find plenty of uses for once you know how it works. Explode() takes two arguments, a…