Ruby、PHP 的交互式控制台

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/453578/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-24 22:47:29  来源:igfitidea点击:

interactive console for Ruby, PHP

phpruby

提问by Test

How do you start the Interactive Console for ruby and php

你如何为 ruby​​ 和 php 启动交互式控制台

回答by Gordon Wilson

For ruby, you want the 'irb' command.

对于 ruby​​,您需要 ' irb' 命令。

For python, you can enter interactive mode with the 'python' command.

对于python,您可以使用“ python”命令进入交互模式。

For php, you enter a basic interactive mode with 'php -a'. Because of its limitations, other interactive shells have sprung up. PHP-Shellis one of them.

对于 php,您使用 ' php -a'进入基本交互模式。由于其局限性,其他交互式 shell 也如雨后春笋般涌现。 PHP-Shell就是其中之一。

回答by Attila Gy?rffy

Also, if you are working with a Ruby On Rails project you could use

此外,如果您正在使用 Ruby On Rails 项目,则可以使用

ruby script/console

from your Rails application root. This is a good approach since you get an interactive ruby shell and the advantage is that loads the entire application stack for you. Pretty handy if you are testing your new code or trying to debug something.

从您的 Rails 应用程序根目录。这是一个很好的方法,因为您获得了一个交互式 ruby​​ shell,优点是可以为您加载整个应用程序堆栈。如果您正在测试新代码或尝试调试某些内容,则非常方便。

回答by troelskn

php doesn't lend itself very well to an interactive shell, because you can't redefine functions and classes. So while there isan interactive shell available, it's not very useful.

php 不太适合交互式 shell,因为您不能重新定义函数和类。因此,尽管一个交互式shell可用,它不是非常有用的。

回答by Robert Elwell

Make sure you have php5-cli installed and type 'php -a' at the command line.

确保您已安装 php5-cli 并在命令行中输入“php -a”。

回答by Gabriel Sosa

you are looking for phpshsame as irb for ruby. php-cli allow you to run scripts for the command line like

您正在寻找与 irb 相同的phpshfor ruby​​。php-cli 允许您为命令行运行脚本,例如

myserver> php -r "echo 'hola mundo';" 

so what you are asking and all replies about php-cli are different. also php-cli has it own php.ini that allow you to have differents configurations depends of run php over httpd (like apache) or in bash

所以你问的是什么,所有关于 php-cli 的回复都是不同的。php-cli 也有它自己的 php.ini 允许你有不同的配置取决于通过 httpd(如 apache)或在 bash 中运行 php

saludos

问候语

回答by chim

There is an excellent script for PHP that allows you to run a php console on a local website.

有一个优秀的 PHP 脚本,允许您在本地网站上运行 php 控制台。

http://seld.be/notes/php-console-in-your-browser

http://seld.be/notes/php-console-in-your-browser

There's obvious security implications here, but if it's only accessible locally, then there's no need to worry.

这里有明显的安全隐患,但如果只能在本地访问,则无需担心。

Really saves time if you want to double check the function behaviour, or to isolate a piece of code and diagnose what happens.

如果您想仔细检查函数行为,或者隔离一段代码并诊断发生了什么,真的可以节省时间。

回答by Mike Lyons

For a console with a rails 3.x+ project loaded

对于加载了 rails 3.x+ 项目的控制台

rails c

this is shorthand for ruby scripts/rails console

这是简写 ruby scripts/rails console

See more abbreviations here: http://xyzpub.com/en/ruby-on-rails/3.2/abkuerzungen.html

在此处查看更多缩写:http: //xyzpub.com/en/ruby-on-rails/3.2/abkuerzungen.html

回答by empi

In php its php or php-cli - different name in different installations

在 php 中,它的 php 或 php-cli - 不同安装中的不同名称