How do I display PHP information using phpinfo()?

Elmi Ahmadov picture Elmi Ahmadov · Jul 3, 2011 · Viewed 98.5k times · Source

I have phpinfo() text which I want to post and display on another PHP page.

My code:

###File index.php

<html>
<form action = "go.php" method = "post">
<input type = "text" name = "msg"><br><br>
<input type = "submit" value = "Submit">
</form>
<html>

###File go.php :

<?php
    $message = $_POST['msg'];
    echo "Message : ". $message;
?>

How can I show PHP info when sending phpinfo() text with post data?

Answer

marchaos picture marchaos · Jul 3, 2011

I'm not sure I'm following you, but it sounds like you want to capture the output of phpinfo(). You can do this with output buffering:

<?php
ob_start();
phpinfo();
$info = ob_end_clean();
?>