Re: own php function
| From: | Hartmut Holzgraefe | Date: | Fri, 07 Sep 2007 20:04:44 +0000 |
| Subject: | Re: own php function | ||
| References: | 1 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-32102@lists.php.net to get a copy of this message | ||
Marten Lehmann wrote:
I would like to create an own php function which just prints a certain report as phpinfo() does. The function shall not be included into the general php code, I just want to patch my own installation. Where would be a good place for the function? I don't want to create an extention which would have to be included into the configure script, I guess thats too much work. The function shall be able to access the Host-header of the webserver.I'd also recommend that you wrap your function into an extension of its own, it is not as hard as it seems ... (warning, shameless plug to follow as usual) .. especially if you let pecl-gen take care of all the infrastructure work so that you can focus on the desired functionality. Assuming that your function does not take any parameter and does not return anything your pecl-gen input file would look like this: <?xml version="1.0"?> <extension name="myinfo"> <function name="myinfo">
<proto>void myinfo(void)</proto>
<code>
<![CDATA[
php_printf("your output here\n");
]]>
</code></function> </extension> Once you've installed CodeGen_PECL from PEAR you can create a working extension from this using the following sequence of commands: pecl-gen myinfo.xml cd myinfo phpize configure make sudo make install After that you can load the extension in php.ini using extension=myinfo.so For more details on pecl-gen see: http://php-baustelle.de/CodeGen_PECL/manual.html -- Hartmut Holzgraefe, Principal Support Engineer . Discover new MySQL Monitoring & Advisory features at: http://www.mysql.com/products/enterprise/whats_new.html Hauptsitz: MySQL GmbH, Dachauer Str.37, 80335 München Geschäftsführer: Kaj Arnö - HRB München 162140