douyoupingji7238 2015-03-27 10:30
浏览 98
已采纳

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

I am using SublimeText to run PHPUnit tests continuosly. 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:

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. If I do the same there (via writing echo shell_exec('php -v');die(); into a PHPUnit test), I get this:

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.

How to tell /bin/bash to use the newly installed PHP version?

  • 写回答

1条回答 默认 最新

  • dongwu9647 2015-03-27 10:35
    关注

    When you issue the command $ php, the PATH is searched for the binary. You can find out which one will be executed with the command $ 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, e.g. $ /opt/php5.6/bin/php.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 uniapp uview http 如何实现统一的请求异常信息提示?
  • ¥15 有了解d3和topogram.js库的吗?有偿请教
  • ¥100 任意维数的K均值聚类
  • ¥15 stamps做sbas-insar,时序沉降图怎么画
  • ¥15 买了个传感器,根据商家发的代码和步骤使用但是代码报错了不会改,有没有人可以看看
  • ¥15 关于#Java#的问题,如何解决?
  • ¥15 加热介质是液体,换热器壳侧导热系数和总的导热系数怎么算
  • ¥100 嵌入式系统基于PIC16F882和热敏电阻的数字温度计
  • ¥20 BAPI_PR_CHANGE how to add account assignment information for service line
  • ¥500 火焰左右视图、视差(基于双目相机)