统一用于C / C ++和PHP应用程序的linux脚本

I have a Linux script that will be used to start/stop applications written in both C/C++ and PHP. With C/C++ I have no problem, but to understand the PHP applications my systems needs php-cgi, and my PHP files need to have the file extension '.php' to be understood (while C/C++ are perfectly understood without an extension).

So if I want to run applications in C/C++ I just write:

"$APPNAMEBIN" > /dev/null 2>&1

But when I have applications in PHP I need to write

php-cgi "$APPNAMEBIN" > /dev/null 2>&1

To make it easier for the user and to unify the rules I want to have an script that simply has one line to run the applications, no matter what programming language was used. And this way be able to omit the file extension too.

So I was thinking if there is a way to put it at the beginning of the script like for example:

#! /path/php-cgi

So my system understand that PHP applications need to run with that.

I am very new in this, so I am not sure if what I am asking for is possible or if there is another way to do this.

Thank you.