|
Cookbook /
PHPExecuteSummary: Lets you execute PHP-Code in any page.
Version: 0.9 2008-12-07
Prerequisites:
Status: BETA
Maintainer: Michael Selbmann
Categories: Administration Markup
Questions answered by this recipeHow can I execute PHP-Code in a page? DescriptionLets you execute PHP-Code in any page. NotesIt was only tested with simple code snippets. Release NotesIt is even not a beta, it is still a gamma-Version. Use at your own risk :-) InstallationPut this in yout local/config.php
Markup('php','<include','/\(\:php\:\)(.*?)\(\:phpend\:\)/sie', "php('$1')");
function php($cmd)
{
$cmd = str_replace('\\"', '"', $cmd);
$out = "";
eval($cmd);
return $out;
}
Now you can execute simple PHP-Code in any pages. Like:
(:php:)
$out = {$FullName} . "\n";
$arr = Array("a", "b", "c");
$cnt = 0;
foreach($arr as $line)
{
$cnt++;
$out .= "||$line||$cnt\n";
}
$out .= "FOO\\\\\n" . "BAR:" . (3*4);
(:phpend:)
ContributorCommentsPatricia - France (bad english) That don't work with : (:php:) and a message error appears on the top : Nota 1 : column-left.php contains a simple table. Nota 2 : the code dont appears in the source code Nota 3 : Your example on the top is correctly work on the same pmwiki page
User notes? : If you use, used or reviewed this recipe, you can add your name. These statistics appear in the Cookbook listings and will help newcomers browsing through the wiki. |