I've tried various things like

php -r "echo phpinfo();" > test.html 

and

echo "<?php phpinfo(); ?>" | php > test.html 

but I get a non-HTML dump. (Don't want to expose details here, as it's a company server.)

I guess PHP is detecting what "client" I am on, and serving a text dump instead of the classic purple HTML page?

7

3 Answers

The user IncredibleHat had the right idea in the comments. I needed a script to return some information from the browser version of phpinfo() and used cURL to get the data I needed.

First make a info.php file:

<?php phpinfo(); ?> 

Then call this file with a cURL GET request using . The URI should include the path to wherever you saved you info.php file.

This will return the HTML of phpinfo(). As a bonus, you can change info.php to instead of returning the HTML result and parse it to return the result in a PHP associative array using the code in user Calin S.'s comment in the PHP reference page:

This way you can easily use anything from the phpinfo() in aother script.

1

You can get the information directly from command line:

>php -i 

to search for something you can grep it:

>php -i | grep 'memory_limit' 
5

This way helped me to get my phpinfo() in html format:

  1. Create some file with phpinfo() in your terminal:

    echo "<?php phpinfo();" > info.php 
  2. Run it on built in php web server and open in web browser, e.g. for ubuntu:

    php -S localhost:8000 | firefox 

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy