Like many people, I picked up PHP from various (usually awful) tutorials and the occasional dip into the documentation. I’ve made it a priority to actually read the manuals and specs for the technologies I use. Here’s some of what I learnt reading the PHP Documentation.
- You can use  array notation to access object properties (or anything else) if you implement the ArrayAccess Interface. The only actual use of this I can think of is for switching to objects instead of arrays but still supporting unmodified scripts. It’d be easier to use the second thing I learnt, though:
PHP can do great type casting. Casting is essentially forcing a variable to assume another type, and takes the following syntax:
$string = (string) $object; # forces the object to become a string
The most useful use of this is to dynamically switch between objects and arrays. If you have some code that might be sent either, just cast the questionable variable to your favourite and use that syntax.
- Any variable can be stored as a bytestream representation with serialize() and resurrected with unserialize() (fellow Brits, watch out for the spelling here!).
- PHP supports a whole load of fake protocols (wrappers), including ones beginning with php:// which give you access to some input and output streams
- If you make a mistake involving the scope resolution operator (double colon, e.g. ::), you may well get an error message with some Hebrew in it.
The Security Section is particularly useful and informative — if you’re only going to read one bit of the manual, make it this one.
It was cool to see a couple of xkcd comics included too.