Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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

This comment has been minimized.

Copy link

@pdt256 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