Tuesday, June 14, 2016

Use different PHP version CLI executable for one command

Maybe you can try to fix the environnement!
$ php -v
PHP 5.4.x (cli) ...
$ set PATH="/usr/lib64/php5.6/bin:$PATH"
$ php -v
PHP 5.6.x (cli) ...
Or, if you don't want to modify the PATH for your shell session, you can scope the change for the current command only:
$ php -v
PHP 5.4.x (cli) ...
$ env PATH="/usr/lib64/php5.6/bin:$PATH" php -v
PHP 5.6.x (cli) ...
$ php -v
PHP 5.4.x (cli) ...
If you can't change path then you can execute command as follows,(Eg: php -v)
First you want to know php-cli path
$ /php-cli-path -v

Eg:-
/usr/local/php70/bin/php-cli -v

No comments: