Elmi Ahmadov
Elmi Ahmadov

Reputation: 1035

How do I display PHP information using phpinfo()?

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?

Upvotes: 16

Views: 157118

Answers (1)

marchaos
marchaos

Reputation: 3444

This question is unclear and probably asked out of some confusion. To display PHP information using phpinfo() you just call this function in a PHP script:

<?php
phpinfo();

and when you navigate to this page in your browser, it will display the PHP information

In the command line you can get the PHP information using -i option:

php -i

If, for some reason, you want to capture the output of phpinfo() in a variable, you can do this with output buffering:

<?php
ob_start();
phpinfo();
$info = ob_get_clean();

Upvotes: 23

Related Questions