试图弄乱 PHP,但我不想安装 IIS 或 Apache,并希望有一个小型解释器,我可以将脚本传递给并让它们像控制台或其他东西一样运行。就像 Lua 一样。这存在吗?当我去下载 PHP 时,它似乎只谈论在 IIS 或 Apache 上运行它。
6 回答
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)
使用 PHP 5.1+ 你也有一个交互式 shell:
使用 -a 参数启动 php
php.exe -a
http://php.net/manual/en/features.commandline.interactive.php
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.
查看easyphp,一个用于php开发的服务器
dtech 的答案似乎最适合您正在寻找的简单脚本运行的东西。如果您决定想要一个实际的 Web 服务器,并且设置尽可能少,请查看"XAMPP"。