Useful PHP snippets, heavily commented