Is there an easy way of seeing PHP info?

Php

Php Problem Overview


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.

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

Php Solutions


Solution 1 - Php

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 

Solution 2 - Php

If you have php installed on your local machine try:

$ php -a
Interactive shell

php > phpinfo();

Solution 3 - Php

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

php -i | grep libxml

Solution 4 - Php

From the CLI:

php -r 'phpinfo();'

Solution 5 - Php

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!

Solution 6 - Php

You can use this command to print phpinfo to file .txt:

> touch phpinfo.txt && php -i >> phpinfo.txt && sudo gedit phpinfo.txt

Explain about that code:

  1. Create new file: > touch phpinfo.txt

  2. Print phpinfo() to file .txt: > php -i >> phpinfo.txt

  3. Open file: > sudo gedit phpinfo.txt

Hope it's help. Thanks.

Solution 7 - Php

If you are using WAMP then type the following in the browser
http://localhost/?phpinfo=-1, you will get the phpinfo page.

phpinfo() from localhost

You can also click the localhost icon in the wamp menu from the systray and then find the phpinfo page. WAMP localhost from WAMP Menu

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionMEMView Question on Stackoverflow
Solution 1 - PhpJamesHalsallView Answer on Stackoverflow
Solution 2 - PhpRagView Answer on Stackoverflow
Solution 3 - PhptotasView Answer on Stackoverflow
Solution 4 - PhpsjasView Answer on Stackoverflow
Solution 5 - PhpChris G.View Answer on Stackoverflow
Solution 6 - PhpfuduView Answer on Stackoverflow
Solution 7 - PhpvenkatView Answer on Stackoverflow