我只想在 Windows 的命令行中运行 PHP。如何开始?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/4841736/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
I just want to run PHP in the command line in Windows. How to get started?
提问by trusktr
In Linux, all I had to do was install PHP and boom, I'm ready to go and can execute PHP scripts via command line.
在 Linux 中,我所要做的就是安装 PHP 和繁荣,我准备好了,可以通过命令行执行 PHP 脚本。
In Windows, is it the same? If I just download the binary and install it, then can I run command line PHP? And also, should I get the thread-safe or non-thread-safe version? I have neither IIS (or do I with Windows 7 Ultimate?) nor Apache. I just want command-line functionality!
在 Windows 中,它是一样的吗?如果我只是下载二进制文件并安装它,那么我可以运行命令行 PHP 吗?而且,我应该获得线程安全版本还是非线程安全版本?我既没有 IIS(或者我有 Windows 7 Ultimate?)也没有 Apache。我只想要命令行功能!
Thanks for the advice!
感谢您的建议!
回答by
It's the same under Windows, you just need to make sure php.exe is in your PATH(in order to use php.exe from any directory) and you need to use CTRL-Z+RETURN for EOF (CTRL-D under Unix):
在 Windows 下也是一样,你只需要确保 php.exe在你的 PATH 中(为了从任何目录使用 php.exe)并且你需要使用 CTRL-Z+RETURN for EOF(在 Unix 下是 CTRL-D) :
sample session:
示例会话:
D:\dev\php>php
<?php
echo 'foo';
?>
^Z
foo
D:\dev\php>