Different versions of PHP on the Server vs CLI
Your path is set to the wrong/older version. Do a export PATH=/usr/local/php5/bin:$PATH
Restart the terminal and php -v
Alternatively have a look at Have a look at: Mac upgraded PHP to 5.6, but CLI php -v get 5.3.28? and follow @mark-reed comment on the @bing answer.
Same issue with my computer.
When i check php version on terminal
Nanhes-MacBook-Pro:~ nanhekumar$ php -v
PHP 7.1.16 (cli) (built: Apr 1 2018 14:10:37) ( NTS )Copyright (c) 1997-2018 The PHP GroupZend Engine v3.1.0, Copyright (c) 1998-2018 Zend Technologies
PHP Version 7.1.25
Solution
you can view installed php through brew list in my case it is showing php@7.1
Nanhes-MacBook-Pro:~ nanhekumar$ brew link php@7.1If you need to have this software first in your PATH instead consider running: echo 'export PATH="/usr/local/opt/php@7.1/bin:$PATH"' >> ~/.bash_profile echo 'export PATH="/usr/local/opt/php@7.1/sbin:$PATH"' >> ~/.bash_profile
Then run this on terminal
echo 'export PATH="/usr/local/opt/php@7.1/bin:$PATH"' >> ~/.bash_profileecho 'export PATH="/usr/local/opt/php@7.1/sbin:$PATH"' >> ~/.bash_profile
Restart terminal and again check your php version both php version are same.