MAMP is a pretty crappy environment, but it beats the shit out of building a decent environment myself and is marginally more convenient than working on a Linux VM. This little script makes it more useful (for me) by providing a fake php command in the $MAMP/Library/bin directory which calls the real php from the version you've configured MAMP to use.
Just put the accompanying script in the $MAMP/Library/bin directory and make it executable, then make sure that $MAMP/Library/bin is in your $PATH before /usr/bin (and any other directory containing an executable called php).
Then any invocation of php will be executed with the correct version (as far as MAMP cares, anyway!)
Future improvements include using the "next" php in $PATH if MAMP is not running.