MEM
MEM

Reputation: 31307

Is there an easy way of seeing PHP info?

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

I'm on Ubuntu.

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

Upvotes: 183

Views: 344838

Answers (8)

Pierre
Pierre

Reputation: 9052

PHP CLI PHPInfo() html solution in Windows

If you need the phpinfo html without having wampp or xampp or apache, do this in command line (remember the directory you run this command in ie. Desktop):

php -S localhost:<random_port> // I used port 7912 in this case

This will start the built-in php development server:

[Wed Oct  2 08:57:17 2024] PHP 8.3.12 Development Server (http://localhost:7912) started

Then in a new command line window in the same directory where you ran the above command (ie. Desktop), create a phpinfo.php file:

echo|set /p="<?php phpinfo(); ?>" >> phpinfo.php

Now we can output the phpinfo() html into a file:

php -r "echo shell_exec('curl -L http://localhost:7912/phpinfo.php');" > phpinfo.html

You can now stop the server in the first command line window by pressing CTRL + C

Upvotes: 0

JamesHalsall
JamesHalsall

Reputation: 13475

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.

Another approach would be to have a PHP script in the root of your web server directory that calls phpinfo();, that way you have access to it at all times via http://localhost/info.php or something similar. However, this is NOT suitable for a production environment unless you ensure that you secure it.

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 

Upvotes: 343

fudu
fudu

Reputation: 742

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

  1. Print phpinfo() to file .txt:

php -i >> phpinfo.txt

  1. Open file:

sudo gedit phpinfo.txt

Hope it's help. Thanks.

Upvotes: 3

venkat
venkat

Reputation: 51

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

Upvotes: 0

totas
totas

Reputation: 10760

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

php -i | grep libxml

Upvotes: 27

sjas
sjas

Reputation: 19668

From the CLI:

php -r 'phpinfo();'

Upvotes: 17

Rag
Rag

Reputation: 6593

If you have php installed on your local machine try:

$ php -a
Interactive shell

php > phpinfo();

Upvotes: 29

Chris G.
Chris G.

Reputation: 3981

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!

Upvotes: 4

Related Questions