PHP - 从终端、ubuntu 服务器执行代码
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/12631907/
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
PHP - Execute code from terminal, ubuntu server
提问by eatonphil
I know that you can run php files from terminal with linux running PHP... I.e. "php script.php" ... But is there any program that allows you to directly input php into the terminal (through any intermediary program) and output the results? I.e. In terminal, testing php globals like getinfo(), etc..? Any help would be great, I'd like to test functions and commands through a sort of run-time terminal. Thanks!
我知道你可以在运行 PHP 的 linux 的情况下从终端运行 php 文件......即“php script.php”......但是是否有任何程序可以让你直接将 php 输入到终端(通过任何中间程序)并输出结果?即在终端中,测试 php 全局变量,如 getinfo() 等......?任何帮助都会很棒,我想通过某种运行时终端测试功能和命令。谢谢!
回答by Jeremy Roman
php -a(as of PHP 5.1) should do what you want.
php -a(从 PHP 5.1 开始)应该做你想做的。
http://php.net/manual/en/features.commandline.interactive.php
http://php.net/manual/en/features.commandline.interactive.php
回答by schurpf
php -r 'phpinfo();'
worked for me on OSX.
在 OSX 上为我工作。
回答by Hammo
You might like a program called PHP Shell Terminal: http://sourceforge.net/projects/phpterm/
您可能喜欢一个名为 PHP Shell Terminal 的程序:http: //sourceforge.net/projects/phpterm/

