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?
73 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.
1You can get the information directly from command line:
>php -i to search for something you can grep it:
>php -i | grep 'memory_limit' 5This way helped me to get my phpinfo() in html format:
Create some file with phpinfo() in your terminal:
echo "<?php phpinfo();" > info.phpRun it on built in php web server and open in web browser, e.g. for ubuntu:
php -S localhost:8000 | firefox