[pmwiki-users] Php code in Wiki page

Patrick R. Michaud pmichaud at pobox.com
Sun Apr 3 09:46:06 CDT 2005


On Sun, Apr 03, 2005 at 01:23:56PM +0200, Ugo Mariani wrote:
> Hi all,
> 
> I'm looking for a way to include some php code in a wiki page, but I don't 
> know which is the preferred medthod.
> 
> Consider a simple example:
> <?php printf("Your host is running PHP version %s", phpversion());?>
> 
> How do I display the result in a Wiki page? Can I just write some special 
> markup? 

Best is probably to write some special markup:

    Markup('phpversion', 'directives',
      '/\\(:phpversion:\\)/e', 
      "sprintf('Your host is running PHP version %s', phpversion())");

> or is it best to create a php file and include it from 
> local/config.php? if so, how can i call the php routine from my Wiki page?

Yes, you can define a function in local/config.php, and then call it:

    function MyVersion() {
      return sprintf('Your host is running PHP version %s', phpversion());
    }

    Markup('phpversion', 'directives',
      '/\\(:phpversion:\\)/e',
      "MyVersion()");

Pm



More information about the pmwiki-users mailing list