Compile PHP as a binary (not as an Apache module). Do to this, change into the dir with the PHP source and go './install' (I think).
Then, write a php script like this:
#!/usr/local/bin/php -q
<?php
echo "This is a test script.";
?>
Then, 'chmod u+x' the php script and you will be able to run it like a normal shell script.
You may wish to go 'set_time_limit(0)' at the top of your script if you expect it to ever run longer than 30 seconds or so.