Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/290.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
PHP7未安装到命令行_Php_Command Line_Path - Fatal编程技术网

PHP7未安装到命令行

PHP7未安装到命令行,php,command-line,path,Php,Command Line,Path,我最近在我的计算机上安装了PHP7,以帮助用python创建测试网站。它已安装所有文件,visual studio在其path变量中接受该文件。然而,当试图从命令行运行PHP命令时,它似乎不起作用 例如: Microsoft Windows [Version 10.0.17134.165] (c) 2018 Microsoft Corporation. All rights reserved. C:\Users\userName>php -a 'php' is not recognize

我最近在我的计算机上安装了PHP7,以帮助用python创建测试网站。它已安装所有文件,visual studio在其path变量中接受该文件。然而,当试图从命令行运行PHP命令时,它似乎不起作用

例如:

Microsoft Windows [Version 10.0.17134.165]
(c) 2018 Microsoft Corporation. All rights reserved.

C:\Users\userName>php -a
'php' is not recognized as an internal or external command,
operable program or batch file.

C:\Users\userName>
我知道命令提示符没有问题,因为我已经安装了Java和Python:

Python示例:

C:\Users\userName>py
Python 2.7.14 (v2.7.14:84471935ed, Sep 16 2017, 20:19:30) [MSC v.1500 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> print "This works!"
This works!
>>>
同样,我可以运行java命令:

C:\Users\userName>java -version
java version "9"
Java(TM) SE Runtime Environment (build 9+180)
Java HotSpot(TM) 64-Bit Server VM (build 9+180, mixed mode)

C:\Users\userName>
我找到了一个解决问题的临时解决方案,它要求我每次编写PHP命令时都设置一个路径:

C:\Users\userName>path C:\Program Files\PHP7

C:\Users\userName>php -a
Interactive shell

php > echo "This works!";
This works!
php >  

任何关于我如何永久修复此问题的答案都将不胜感激

您必须将path环境变量设置为php,以防您想直接使用命令“php”


我认为这将对您有所帮助:

您必须将path环境变量设置为php,以防您想直接使用命令“php”


我想这会对您有所帮助:

谢谢!它就像一个符咒。希望现在有更多的人看到这条线。谢谢你的帮助!:汉克斯!它就像一个符咒。希望现在有更多的人看到这条线。谢谢你的帮助!:D