November 2009

Improve PHP file loading

I think you have already known that require/include is faster than require_once/include_one. But sometime, we also need the functionality of require_once but do not suffer from the performance tradeoff. So here is a better way to re-invent PHP implement.

function requireOnce($file)
{
static $dict=array();

if (!isset($dict[$file]))
{
require $file;
$dict[$file] = true;
}
}

Category:

The best way to access PHP global variable

I have been playing with PHP minor optimization for a while, but this is the first time I go for it seriously. My question for today is what's the best way to work with PHP global variables and how to achieve best performance for it. Rumours say that global keyword is slow, so this is a good time to check it out. And I also want to check if the number of variables affects the performance of the method.

Setup

Category:

The easy way to get GMail contact list

If you're looking for a solution to get contact list / address book in Gmail, you're in the right place. I was looking for the solution too. Actually, I also want to grab contact list from other popular service such as Live, Yahoo! Mail, etc ... but I started with Gmail first. The requirement is simple: the user provides email and password, the application will perform some requests to google and return the contact list.

Category: