0

试图弄乱 PHP,但我不想安装 IIS 或 Apache,并希望有一个小型解释器,我可以将脚本传递给并让它们像控制台或其他东西一样运行。就像 Lua 一样。这存在吗?当我去下载 PHP 时,它似乎只谈论在 IIS 或 Apache 上运行它。

4

6 回答 6

8

PHP can be used on the command line. Just download and extract the executable.

Running can be done 3 ways: a file, supplied code or in an interactive shell

php file.php
php -r "echo 'hello';"
php -a

You can also install a pre-packaged server (e.g. XAMPP) or run your code online on various places (e.g. phpfiddle.org)

于 2013-05-17T14:11:20.133 回答
2

使用 PHP 5.1+ 你也有一个交互式 shell:

使用 -a 参数启动 php

php.exe -a

http://php.net/manual/en/features.commandline.interactive.php

于 2013-05-17T14:14:32.070 回答
0

I believe that PHP v5.4 comes with its own webserver built-in. Install that version and you should be fine. Though I really would like to know why you have problem with installing Apache (IIS sucks though).

EDIT: As a few others have said, you can run PHP from the command line.

于 2013-05-17T14:12:11.533 回答
0

查看easyphp,一个用于php开发的服务器

于 2013-05-17T14:12:12.107 回答
0

http://php.net/cli

或者,您可以像往常一样编写 PHP 脚本(有一些限制),

并使用以下命令行:

C:\php.exe -f "D:\phpFile.php"
于 2013-05-17T14:12:32.060 回答
0

dtech 的答案似乎最适合您正在寻找的简单脚本运行的东西。如果您决定想要一个实际的 Web 服务器,并且设置尽可能少,请查看"XAMPP"

于 2013-05-17T14:14:10.647 回答