If you want to run a php-script on the command-line, you should use a shebang pointing to the absolute path. A shebang is the first line in a script telling the shell which program to use to execute it:
#!/path/to/your/alternative/php
then make your script executable and just run it:
chmod +x yourscript.php
./yourscript.php
Or you just call it directly with the binary of your alternative php-version:
/path/to/your/alternative/php yourscript.php
manpreet
Best Answer
2 years ago
I need to execute a PHP file with another PHP version as installed. I know the full path to the other versions, but I do not know how to use it.
I have read the PHP man page but there is no mention of it. I assume I have to set the version first and then run it.
I know how to do it via
htaccess
, but isn't there a way to set the version directly in the command line?