1

PHP Version: 8.2.12

I have been looking for the HTML structure of:

<?php
 phpinfo();
?>

I know the details of the call comes largely from php.ini on my web server, but I can't figure out where that call gets it's output structure. Right now, it outputs the page in a table structure. I would like to convert that to a div structure for CSS Grid. Any ideas here?

I have looked all over the net for a single article that discusses the output of the phpinfo() command. All I have found is ideas about wrapping the command in a function. But, that still doesn't tell me anything about the way the command is contained in the html "inspector" view.

3
  • 2
    stackoverflow.com/questions/6035850/… may help.
    – Nigel Ren
    Commented Jun 7 at 14:37
  • I assume it decides whether to use plain text or an HTML table based on the SAPI. CLI gets plain text, web gets HTML.
    – Barmar
    Commented Jun 7 at 14:45
  • "details of the call comes largely from php.ini" — Not at all. You can run PHP with no INI file at all and still get the same pieces of info. Almost all the directives have default values compiled in, many of which can be changed afterwards in several different ways, often during runtime. And of course, credits and copyright information are hard-coded. If you have the time and inclination, and you don't want to build your own HTML around plain text version, you can use DOM methods to parse and alter the HTML structure. Commented Jun 7 at 16:42

1 Answer 1

3

The phpinfo output is defined in there : https://heap.space/xref/PHP-8.3/ext/standard/info.c

You can see most of the markdown is inlined directly in the PHP source.

6
  • That link seems to have broken, but here's one to the php_print_info_htmlhead() function listed on GitHub, showing the mark_up_ is, in fact, inlined HTML. Commented Jun 8 at 16:57
  • @Arthur Boucher, sorry for the delay in response. Thank you for your response. However, I am a little confused on a couple things: 1. Where do you edit this file? The file you linked is called "info.c". Is this a standard php file? Does this file come with xampp's PHP installation or is this a custom script I would need to add to xampp or my project root? 2. If I were to edit this script, how would you switch the output of phpinfo() from table to div in the code? I ask cause phpinfo() in PHP 8.2.12 has multiple tables in it's generated html table code.
    – Josh1985
    Commented Jun 10 at 13:23
  • The file is a C file, it is part of the PHP source code, which is then compiled to produce the files you can see in the php folder of your xampp installation. The easiest way to edit them would be to clone the php repository from github, edit the C files, and build your own PHP version. It would require a significant amount of work, and I would generally advise against deploying a home-made fork of PHP in a production environment. The easier route I think would be to parse the output of the php -i command, and build your HTML from that. Commented Jun 10 at 13:59
  • @Arthur Bocher, Thanks for your response. However, I think we are getting a little outside the scope of my original question and into the weeds a bit here though. I don't know how we even got into talking about other languages such as a C file or the php CLI. I was asking how to run 'code'<?php phpinfo(); ?> 'code' in a basic php file where I could simply change the container(s) of the output data? You mentioned parsing the output of the 'code' php -i 'code' command but I don't see where you specified how to do that in your response?
    – Josh1985
    Commented Jun 12 at 13:59
  • If what you want is to store the output of phpinfo() into a variable before echoing it, you can do so by calling ob_start();, followed by phpinfo();, and then $info = ob_get_clean();. The $info variable now contains the HTML output of phpinfo(), and you're free to manipulate it, with the php DOM extension for an example. Commented Jun 12 at 14:43

Not the answer you're looking for? Browse other questions tagged or ask your own question.