bash脚本来执行php文件

我想写一些东西检测PHP安装,然后执行PHP后,例如:

./find_php.sh /path/to/php/file.php

所以我可以得到它来检测我想要使用的PHP,并将其粘贴在一个variables,但我不知道如何得到它来执行下面的PHP文件。 这是我得到的骨架:

#!/bin/bash if [ -e /usr/local/zend/bin/php ]; then PHP=/usr/local/zend/bin/php else PHP=/usr/bin/php fi $PHP <execute php> 

编辑 – 感谢得到它,只需要exec $ PHP“$ @”

做你的最后一行:

 exec $PHP "$@" 

这将运行你的脚本的参数,并让它接pipeshell脚本进程的php二进制文件。

如果你想让你的脚本在执行php脚本之后做其他的事情,那么删除exec