I'm sure PHP has to be installed as a CGI on Linux to perform PHP script execution such as that.
I was successful with this;
simple.php
<?
for($i=0;$i<10;$i++) {
print $i;
}
?>
[**@** home]# php -q simple.php
This runs the simple.php script in the shell.
You don't even need to chmod the file.