Forum Moderators: coopster

Message Too Old, No Replies

Including phpinfo() in a page

         

Nutter

1:13 pm on Jun 10, 2006 (gmt 0)

10+ Year Member



I've got a page that I want to include a phpinfo() function on, but when I do that phpinfo() outputs a complete page, CSS styling and all, which causes my layout to break. Is there a way to get the information from phpinfo without it thinking it's on its own page?

henry0

2:06 pm on Jun 10, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Sounds like a good case where using target="_blank"
may not be that bad!
You could have a link to a page with only the phpinfo() and set the url to that page with a target.

Nutter

2:09 pm on Jun 10, 2006 (gmt 0)

10+ Year Member



Nah, I want to keep in on a page. What I'm thinking is to capture the output of phpinfo() with ob_start() and then use preg_replace to strip out the <head> section (which includes the CSS), the DOCTYPE declaration, and the opening & closing html & body tags. Then echo it out. Of course now I've got to figure out preg_replace and regular expressions are something I've managed putting off really understanding :-)

henry0

2:15 pm on Jun 10, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Search for "print function" and poke around.
I have seen somewhere a function that "trims" the x-tra stuffs.
Then you could echo it instead of printing.

encyclo

2:17 pm on Jun 10, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Would just keeping the existing styles and opening it in an
iframe
be enough?

Nutter

2:40 pm on Jun 10, 2006 (gmt 0)

10+ Year Member



I wound up putting it an iframe, although I still would prefer to have it be on page. But it'll work for now until I've got more time to mess with it - it's not a critical part of the app anyway.

I got all the junk stripped out and had it working, except that it caused one of the tabs on my page to mess up. Several other tabs that were styled exactly the same worked fine, so I'll have to spend some time figuring out why that particular one was messed up.

coopster

9:38 pm on Jun 10, 2006 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



Is there a particular reason you want to do this? For example, is it merely to display the configuration directives? Or do you truly want to display all the different sections (see the CONSTANTS on the phpinfo() [php.net] page)? If you merely want the configuration directives you could use ini_get_all() [php.net].