Monday, 13 August 2018

Writing phpinfo() To File

The contents of phpinfo() are quite useful, and it is usually the first thing that many developers perform to make sure that PHP is installed. However, printing out the phpinfo() function can lead to a security risk because it displays a lot of information about the server.
Here is how to write the contents of the phpinfo() function to a file.
  1. $info = ob_get_contents();
  2.  
  3. $fp = fopen("phpinfo.html", "w+");
  4. fwrite($fp, $info);
  5. fclose($fp);
This is an example of output buffering.

0 comments:

Post a Comment