phpinfo - an easy way for seeing it?

2019-01-30 12:56发布

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

create a info.php file; write phpinfo(); in it. go to the browser and type my "thisproject.dev/info.php"

I'm on Ubuntu and my question is.. Isn't there a more practical way to see phpinfo on the browser ?

Thanks

标签: php phpinfo
5条回答
The star\"
2楼-- · 2019-01-30 13:19

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

Something like that? Idk!

查看更多
Rolldiameter
3楼-- · 2019-01-30 13:21

From the CLI:

php -r 'phpinfo();'
查看更多
别忘想泡老子
4楼-- · 2019-01-30 13:31

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.php or something similar (NOTE: don't do this in a production environment or somewhere that is publicly accessible)

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...

php -c /etc/php/apache2/php.ini -i 
查看更多
姐就是有狂的资本
5楼-- · 2019-01-30 13:37

If you have php installed on your local machine try:

$ php -a
Interactive shell

php > phpinfo();
查看更多
爷、活的狠高调
6楼-- · 2019-01-30 13:39

From the CLI the best way is to use grep like:

php -i | grep libxml
查看更多
登录 后发表回答