Recent Posts
- (09/10) Fixing Warning: the ECDSA host key for 'github.com' differs from the key for the IP addressTAGS:Web Server Admin
- (12/26) CakePHP 3 - Getting List of Column Definitions from a Table (like schema())TAGS:CakephpCake3
- (09/14) Change Order of Loaded Behaviors in CakePHP 3TAGS:Cake3CakephpWeb ProgrammingPhp
- (05/29) CakePHP 3 - Accept JSON Header Only Working When Debug FalseTAGS:Web ProgrammingCakephpCake3
- (05/23) Remove All Events from Google Calendar (Reset Calendar)TAGS:Web ProgrammingPhp
- (11/08) Google Tag Manager (GTM) Not Firing Default PageView EventTAGS:Web ProgrammingJavascriptGoogle Tag Manager
- (10/13) In PHP, how do you get __toString() Magic Method Result without calling echo?TAGS:CakephpCake3Cakephp 13PhpWeb Programming
- (11/14) Getting output from shell_exec() at all timesTAGS:Web ProgrammingWeb Server Admin
Subscribe to my feed
MainelyDesign.com Blog
Displaying phpinfo() without CSS styles
Posted on 06/09/2009 at 10:18 am by Kevin Wentworth
Viewed 23,407 times | 1 comment
I wanted logged in users to be able to see the output from phpinfo(); within Site Avenger. The problem with using phpinfo() is that it outputs a full HTML page, CSS styles and all. In the past this has been fine, but now I wanted to show the phpinfo() within the Site Avenger layout and CSS styles. I came across a simple, yet highly effective solution...
Using Output Buffering to Capture PHPINFO()
The solution is as simple as turning on output buffering, capturing the echo'ed value of phpinfo(); and then using preg_replace to only return what's in between the <body></body> tags. Here's the code:
- echo $pinfo;
Styling PHPINFO() with CSS
I didn't want to use any styles (they were already defined for Site Avenger), so this is just a reference. You can style the phpinfo() table using the following CSS selectors:
- <style type="text/css">
- #phpinfo {}
- #phpinfo pre {}
- #phpinfo a:link {}
- #phpinfo a:hover {}
- #phpinfo table {}
- #phpinfo .center {}
- #phpinfo .center table {}
- #phpinfo .center th {}
- #phpinfo td, th {}
- #phpinfo h1 {}
- #phpinfo h2 {}
- #phpinfo .p {}
- #phpinfo .e {}
- #phpinfo .h {}
- #phpinfo .v {}
- #phpinfo .vr {}
- #phpinfo img {}
- #phpinfo hr {}
- </style>
Thanks, to this post at php.net for leading me to such an elegant solution.
Cheers,
-Kevin Wentworth
Tags for Displaying phpinfo() without CSS styles
Cakephp | Web Programming | Site Avenger | Php | Css
Comments for this Posting
Sorry, comments are closed for this posting.
Please Email Kevin if you have any questions. Thanks!
Posted by MadtownLems
on 26/5/10
Worked great for my WordPress plugin! thanks!