Recently I installed XAMPP for doing local development on my Windows 7 machine. I honestly didn't think PHP was installed at all before hand. I installed the latest version of XAMPP and configured for php 5.6.24. I created some virtual hosts and everything seemed to work.
I was having an issue and I needed to confirm which version of PHP I was using so I opened up my command line and typed php -v
. For some reason it is reporting I'm using PHP 5.4.25. The exact line is PHP 5.4.25 (cli) (built: Feb 5 2014 21:19:58)
I don't recall using this version (I had Visual Studio Community installed recently, is that related?). I don't understand either why my CLI is reporting one version, when XAMPP supposedly installed another version. Am I missing something? I need to run some gpm commands for the latest version of Grav CMS
but when I do it says it required at least 5.5.9.
It is possible to have multiple versions of php installed.
You will want to ensure that you are executing the php-cli that came with XAMPP.
It sounds like you have another version of php installed and is in your PATH
so that when you run php
that version is loaded.
You can use the where
command to find out what file is being loaded.
From the terminal type: where php
- I am not a windows guy but there is a
which
command on linux. Apparently this is the command for windows. Here is a SO post about it: Is there an equivalent of 'which' on the Windows command line?
Anyways, you may want to remove that php file and possibly create a symbolic link in its place for the XAMPP version of php-cli
If you remove/rename the file and the new php-cli
is not in your path, you will probably get an error as the system will not know what php
is.
The solution to this is to uninstall all the xampp's that are installed and then fresh install xampp with php version > 7.
Everything should work fine then.
What happened to me was that I had installed xampp two times. One xampp on my C:// (version 5.6) and one xampp on my D:// (version 7.2)
When I did the command on my D:// xampp
php --version
It took the xampp php version from the C:// instead of the D://.
来源:https://stackoverflow.com/questions/40181900/php-cli-version-doesnt-match-xampp-version-i-installed