different result between phpinfo.php and php-v

|▌冷眼眸甩不掉的悲伤 提交于 2020-01-14 09:37:46

问题


i was using appserv 5.8 and in my phpinfo.php the php version was 5.6.26 now i installed laravel5.5 and its required phpversion 7 so i changed the php version to 7 from 5 now in my phpinfo.php

PHP Version 7.0.11

and when i write in the command

php -v

its give me

PHP 5.6.26 (cli) (built: Sep 15 2016 18:12:07)
Copyright (c) 1997-2016 The PHP Group
Zend Engine v2.6.0, Copyright (c) 1998-2016 Zend Technologies

and i cant install the packages with laravel 5.5 bc the version in command line is 5.6 not 7 but when i check in phpinfo its 7 i have read something thats the command php -v tack the version from php-cli so how can i change the php -v to be 7.0.1 as phpinfo.php thanks ..


回答1:


phpinfo.php shows what version of PHP Apache is using. -v shows what's in your $PATH.

If you're on a Mac I recommend using homebrew to install php 7 as described here

To clarify, PHP can be run in 3 ways: behind a web server, for command line scripting, and for GUI building. You have 2 versions: the web server one, which Apache is calling and invoking phpinfo.php, and PHP-CLI, which is invoked from the command line with php -v.




回答2:


It seems like your PHP CLI version is different than the PHP web version. Upgrade your PHP CLI package.




回答3:


You have two PHP binaries installed. In my Mac OSX:

$ which php
/usr/local/bin/php

$ /usr/local/bin/php -v
PHP 7.0.20 (cli) (built: Jul 12 2017 09:47:44) ( NTS )

And in same machine:

$ whereis php
/usr/bin/php

$ /usr/bin/php -v
PHP 5.6.30 (cli) (built: Feb  7 2017 16:18:37)

You should put /usr/local/bin in your PATH. Edit ~/.bash_profile

export PATH=/usr/local/bin:/usr/local/sbin:$PATH

Open a new terminal and check your php version.



来源:https://stackoverflow.com/questions/46018531/different-result-between-phpinfo-php-and-php-v

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!