|
|
 |
After creating a real module, you'll want to show information
about the module in phpinfo() (in addition to the
module name, which appears in the module list by default). PHP allows
you to create your own section in the phpinfo() output with the ZEND_MINFO() function. This function
should be placed in the module descriptor block (discussed earlier) and is
always called whenever a script calls phpinfo().
PHP automatically prints a section
in phpinfo() for you if you specify the ZEND_MINFO
function, including the module name in the heading. Everything else must be
formatted and printed by you.
Typically, you can print an HTML table header
using php_info_print_table_start() and then use the standard
functions php_info_print_table_header()
and php_info_print_table_row(). As arguments, both take the number of
columns (as integers) and the column contents (as strings). Example 56-1 shows a source example and its output. To print the table footer, use php_info_print_table_end().
Example 56-1.
Source code and screenshot for output in phpinfo().
php_info_print_table_start();
php_info_print_table_header(2, "First column", "Second column");
php_info_print_table_row(2, "Entry in first row", "Another entry");
php_info_print_table_row(2, "Just to fill", "another row here");
php_info_print_table_end(); |

|
User Contributed Notes
Including Output in phpinfo
jason dot lambert at uk dot clara dot net
08-Apr-2004 07:40
That documentation didnt really explain anything to me, i went looking at the php source code to work out how to do this.
For the benifit of anyone wishing to place information about their module in the output of phpinfo(), here is how its done:
// define the special info function
ZEND_MINFO(firstmod);
//
// Now define our module entry
//
zend_module_entry firstmod_module_entry =
{
STANDARD_MODULE_HEADER,
"First Module",
firstmod_functions,
NULL, NULL, NULL, NULL,
ZEND_MINFO(firstmod), //this is for your phpinfo() function!
NO_VERSION_YET,
STANDARD_MODULE_PROPERTIES,
};
//
// Create a new function that handles phpinfo() stuff...
//
ZEND_MINFO_FUNCTION(firstmod)
{
char *somevalue = "blah blah";
php_info_print_table_start();
php_info_print_table_header(2, "Data", "Value");
// example using compiler macro
// for the build time/date
php_info_print_table_row(2, "Build Date", __DATE__);
php_info_print_table_row(2, "Build Time", __TIME__);
// you can use normal c variables and
// call external functions here as well..
php_info_print_table_row(2, "Some other stuff", somevalue);
php_info_print_table_end();
}
Have fun!
-------------------------
Jason Lambert
http://www.linuxforums.org/
| |