简体   繁体   English

PHP7无法从命令行运行

[英]PHP7 not working from the command line

I just installed PHP7 on my windows 10 machine from here (the thread safe 64 bit version) http://windows.php.net/download#php-7.0 我刚刚从此处(线程安全64位版本)在Windows 10计算机上安装了PHP7( http://windows.php.net/download#php-7.0)

I manually set the path to the php folder and set up the php.ini . 我手动将路径设置到php文件夹并设置php.ini Whenever I want to use the php command it just goes into the next line without doing anything. 每当我想使用php命令时,它就不执行任何操作就进入下一行。 It doesn't even matter what arguments I type in. There is no error message so I am clueless on what could be the problem. 我输入什么参数都没有关系。没有错误消息,所以我对可能的问题一无所知。

Here is what happens: 这是发生了什么:

PS C:\Users\Jakob> php
PS C:\Users\Jakob> php cjasdf
PS C:\Users\Jakob>

Even if i navigate into the php folder and execute the php.exe nothing happens as well: 即使我导航到php文件夹并执行php.exe也不会发生任何事情:

PS C:\php> .\php.exe
PS C:\php> .\php.exe aleass
PS C:\php>

RE: Your comment about a missing Visual C/C++ runtime library RE:您对缺少Visual C / C ++运行时库的评论

The first thing you need to do is update Windows with that runtime library Download it from here 你需要做的第一件事就是与运行时库更新的Windows 从这里下载

Ok Power Shell is A completely different beast to the command prompt and all the usual DOS commands are replaced with PS commands Ok Power Shell是与命令提示符完全不同的野兽,所有常用的DOS命令都替换为PS命令

I got PHP to run in Power Shell like this 我让PHP这样在Power Shell中运行

Running PHP by switching into the folder where PHP is installed 通过切换到安装PHP的文件夹来运行PHP

 PS > Set-Location c:\php
 PS > php -v

And here is how I would do it better, by adding the C:\\php folder to the PATH, but only for the duration of the PS Windows instance ie not a permanant change to the Windows PATH 这是通过将C:\\php文件夹添加到PATH(但仅在PS Windows实例的持续时间内),而不是对Windows PATH的永久更改,将其做得更好的方法

Add your PHP folder to the WINDOWS PATH for the duration of this PS execution 在此PS执行期间,将您的PHP文件夹添加到WINDOWS PATH中

PS > $ENV:Path = $ENV:Path + ";c:\php"

The CD (or the PS equivalent) into the folder containing your PHP CLI scripts CD(或PS等效文件)放入包含PHP CLI脚本的文件夹中

PS > Set-Location c:\php-source
PS > php test.php

Thanks, I have never used Power Shell before and finding this simple stuff out made me think I should spend some time learning more about it. 谢谢,我以前从未使用过Power Shell,发现这些简单的东西使我觉得我应该花一些时间来学习更多有关它的知识。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM