简体   繁体   English

如何告诉/ bin / bash正确的php版本? (小牛)

[英]How to tell /bin/bash the correct php version? (Mavericks)

I am using SublimeText to run PHPUnit tests continuosly. 我正在使用SublimeText连续运行PHPUnit测试。 Works great, but now I stumbled upon something strange. 效果不错,但现在我偶然发现了一些奇怪的东西。 I updated to the latest PHP version via Homebrew and if I open a Terminal session and type php -v , this is what I get: 我通过Homebrew更新到了最新的PHP版本,如果我打开一个Terminal会话并输入php -v ,这就是我得到的:

PHP 5.6.7 (cli) (built: Mar 22 2015 19:03:55) 
Copyright (c) 1997-2015 The PHP Group
Zend Engine v2.6.0, Copyright (c) 1998-2015 Zend Technologies

The shell instance that is used by SublimeText seems not to use this version of PHP. SublimeText使用的shell实例似乎不使用此版本的PHP。 If I do the same there (via writing echo shell_exec('php -v');die(); into a PHPUnit test), I get this: 如果我在那里做同样的事情(通过将echo shell_exec('php -v');die();写入PHPUnit测试),我会得到:

PHP 5.4.24 (cli) (built: Jan 19 2014 21:32:15) 
Copyright (c) 1997-2013 The PHP Group
Zend Engine v2.4.0, Copyright (c) 1998-2013 Zend Technologies

I tested around a bit and found out, that automator puts out the same if I run a shell script in \\bin\\bash shell via automator's 'run shell script' action. 我经过了一些测试,发现,如果我通过automator的'run shell script'操作在\\ bin \\ bash shell中运行shell脚本,则该automator也会输出相同的内容。

How to tell /bin/bash to use the newly installed PHP version? 如何告诉/ bin / bash使用新安装的PHP版本?

When you issue the command $ php , the PATH is searched for the binary. 发出命令$ php ,将在PATH中搜索二进制文件。 You can find out which one will be executed with the command $ which php . 您可以使用命令$ which php找出执行哪一个。

If you want to explicitly run one or another php binary when multiple ones are installed, use full absolute path to the binary, eg $ /opt/php5.6/bin/php . 如果要在安装多个php二进制文件时显式运行该二进制文件,请使用二进制文件的完整绝对路径,例如$ /opt/php5.6/bin/php

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM