php phpinfo() - 有没有一种简单的方法可以查看它?

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

phpinfo() - is there an easy way for seeing it?

phpphpinfo

提问by MEM

Each time I want to see the phpinfo();I have to:

每次我想看到phpinfo();我必须:

  • Create a info.php file;
  • Write phpinfo();in it.
  • Go to the browser and type my "thisproject.dev/info.php"
  • 创建一个 info.php 文件;
  • phpinfo();在里面。
  • 转到浏览器并输入我的“thisproject.dev/info.php”

I'm on Ubuntu.

我在 Ubuntu 上。

Isn't there a more practical way to see phpinfo in the browser?

有没有更实用的在浏览器中查看phpinfo的方法?

回答by JamesHalsall

From your command line you can run..

从你的命令行你可以运行..

php -i

I know it's not the browser window, but you can't see the phpinfo();contents without making the function call. Obviously, the best approach would be to have a phpinfo script in the root of your web server directory, that way you have access to it at all times via http://localhost/info.phpor something similar (NOTE: don't do this in a production environment or somewhere that is publicly accessible)

我知道这不是浏览器窗口,但不phpinfo();调用函数就看不到内容。显然,最好的方法是在您的 web 服务器目录的根目录中有一个 phpinfo 脚本,这样您就可以随时通过http://localhost/info.php或类似的东西访问它(注意:不要在生产环境或其他地方这样做可公开访问)

EDIT: As mentioned by binaryLV, its quite common to have two versions of a php.ini per installation. One for the command line interface (CLI) and the other for the web server interface. If you want to see phpinfo output for your web server make sure you specify the ini file path, for example...

编辑:正如 binaryLV 所提到的,每个安装有两个版本的 php.ini 是很常见的。一个用于命令行界面 (CLI),另一个用于 Web 服务器界面。如果要查看 Web 服务器的 phpinfo 输出,请确保指定 ini 文件路径,例如...

php -c /etc/php/apache2/php.ini -i 

回答by Brian Gordon

If you have php installed on your local machine try:

如果您在本地机器上安装了 php,请尝试:

$ php -a
Interactive shell

php > phpinfo();

回答by totas

From the CLI the best way is to use greplike:

从 CLI 最好的方法是使用grep像:

php -i | grep libxml

回答by sjas

From the CLI:

从 CLI:

php -r 'phpinfo();'

回答by Chris G.

Use the command line.

使用命令行。

touch /var/www/project1/html/phpinfo.php && echo '<?php phpinfo(); ?>' >> /var/www/project1/html/phpinfo.php && firefox --url localhost/project1/phpinfo.php

touch /var/www/project1/html/phpinfo.php && echo '<?php phpinfo(); ?>' >> /var/www/project1/html/phpinfo.php && firefox --url localhost/project1/phpinfo.php

Something like that? Idk!

类似的东西?我知道!