hsm*_*mit 5 php python terminal command-line code-testing
使用Python我可以通过键入来测试终端/命令行中的代码
python
python> print "hello world"
Run Code Online (Sandbox Code Playgroud)
我也想用PHP做这件事,但输入时:
php
echo "hello world";
Run Code Online (Sandbox Code Playgroud)
它不起作用..这可能吗?我该怎么办?在互联网上快速搜索会产生大量结果,这些结果可以调用实际的.php文件来运行.我只想在可能的情况下测试单个句子,而不创建文件和内容.
尝试
php -a
Run Code Online (Sandbox Code Playgroud)
它启动了一个交互式PHP shell.请注意,这需要使用--with-readline构建PHP (如果您使用带有Mac OS X的Bundeled PHP,则不是这种情况).
或者,如果您不需要单独shell的交互性,请使用
php -r 'print_r(get_defined_constants());'
Run Code Online (Sandbox Code Playgroud)
执行PHP代码段(这不需要readline支持).