own php function

php.internals

Marten Lehmann

18 years ago
Hello, 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. Regards Marten

David Coallier

18 years ago
On 9/7/07, Marten Lehmann <lehmann@cnm.de> wrote:
> Hello, > > 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. > > Regards > Marten > > -- > PHP Internals - PHP Runtime Development Mailing List > To unsubscribe, visit: http://www.php.net/unsub.php > >
You could make your own extension.. in order to write them (Because after writting one you realize you need more) you should be using either that book by Sara: http://www.amazon.com/dp/067232704X?tag=libssh2projec-20&camp=14573&creative=327641&linkCode=as1&creativeASIN=067232704X&adid=01HQSM6RF0V2X97Y0VPW& Or Start by reading: http://devzone.zend.com/article/1021-Extension-Writing-Part-I-Introduction-to-PHP-and-Zend And I would probably direct you towards pecl-dev@lists.php.net The reason I am mentioning to make your own extension is to save you the hassle of migrating from a version to another. If you make your extension you can easily package it, and when you recompile/re-install php, you just pecl install MyOwnExtension or such.
-- David Coallier, Founder & Software Architect, Agora Production (http://agoraproduction.com) 51.42.06.70.18

Johannes Schlueter

18 years ago
Hi Marten, On Friday 07 September 2007 07:57:53 pm Marten Lehmann wrote:
> Hello, > > 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.
A custom extension looks like the perfect place for such a thing since changes in PHP will less likely break it and you can simply copy it from PHP version to PHP version without having to care aobut changes in PHP... johannes
> Regards > Marten
-- Johannes Schlüter http://schlueters.de

Hartmut Holzgraefe

18 years ago
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

Marten Lehmann

18 years ago
Hello, thanks for all ideas, I will have a look at it very shortly. Regards Marten