Skip to content

Instantly share code, notes, and snippets.

@randomecho
Created June 27, 2014 03:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save randomecho/b64aafd18dc4972613dd to your computer and use it in GitHub Desktop.
Save randomecho/b64aafd18dc4972613dd to your computer and use it in GitHub Desktop.
Grab, strip and dump out phpinfo() into part of a page, neutering some of its overriding HTML and styles.
ob_start();
phpinfo();
$phpInfo = ob_get_clean();
$phpInfo = preg_replace('/600(px)?/', '100%', $phpInfo); // table and hr width
$phpInfo = str_replace('75%', '95%', $phpInfo); // font-size
$phpInfo = preg_replace('/<?([\w]|<|\/|>)*(a:|!DOCTYPE|<html|title|body)(.+)?\\n?/', '', $phpInfo); // main html doc tags
@pdt256
Copy link

pdt256 commented Sep 16, 2014

For PHP 5.6:

ob_start();
phpinfo();
$php_info = ob_get_clean();
$php_info = preg_replace('/934(px)?/', '100%', $php_info);
preg_match('#().*(.*)#s', $php_info, $matches);

echo $matches[1];
echo $matches[2];

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment