When I took the Zend certification exam, one of the areas I really wasn't very clear on was PHP's stream wrappers. Since reading up on them for the exam, I've been kicking myself for not using them before, the amount of simplification they allow for common code is ridiculous.
As an example, a colleague recently showed me some code he'd written that downloaded a .dat.gz file from a remote server, saved it to disk, unzipped it and save the expanded contents into a file. The original code he showed me was similar to the following (with a lot more error checking and comments):
<?php
$tempfile = tempnam(sys_get_temp_dir());
// get the file from FTP to local disk
$fh = ftp_connect('ftphost.com', 21);
ftp_login($fh, 'username', 'password');
ftp_get($fh,$tempfile, '/path/to/file.dat.gz');
ftp_close($fh);
// read data from local .gz into var
$gh = gzopen($tempfile, 'r');
$data = gzread($gh, 1000000);
gzclose($gh);
unlink($tempfile);
// write data to local .dat
file_put_contents('/local/copy/of/file.dat', $data);
The first thing to note is that the ftp functions have an underscore in, while the gz functions don't. To me at least, this makes it almost impossible to remember without constantly referring to the reference. The second thing to note is that by downloading the file to disk first, then reading it into memory, then writing it to disk, we're doing a three-step process.