I have installed homebrew-php php72 on OSX high sierra. Strangely when I run php I still get the pre-installed php 7.1 - even more strangely when I run which php
it tells me that it will use the homebrew version from /usr/local/bin
not the pre-installed version in /usr/bin
. I dont have an aliases set up.
Some shell output:
$ echo $PATH
/usr/local/bin:/bin:/usr/bin:/usr/sbin:/sbin:/opt/X11/bin
$ which php
/usr/local/bin/php
$ php --version
PHP 7.1.7 (cli) (built: Jul 15 2017 18:08:09) ( NTS )
Copyright (c) 1997-2017 The PHP Group
Zend Engine v3.1.0, Copyright (c) 1998-2017 Zend Technologies
$ /usr/local/bin/php --version
PHP 7.2.3 (cli) (built: Mar 8 2018 10:30:06) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologies
with Zend OPcache v7.2.3, Copyright (c) 1999-2018, by Zend Technologies
$ /usr/bin/php --version
PHP 7.1.7 (cli) (built: Jul 15 2017 18:08:09) ( NTS )
Copyright (c) 1997-2017 The PHP Group
Zend Engine v3.1.0, Copyright (c) 1998-2017 Zend Technologies
$ alias | grep php # There are no aliases
$
$ type -a php
php is /usr/local/bin/php
php is /usr/bin/php
I cant think of any reason this could happen any ideas?
Thanks NFV
As discussed in the commands hash -r
fixed the issue. From help hash
:
-r forget all remembered locations
And just for the record: Why not use “which”? What to use then?