note 43661 added to ref.xslt
| From: | ivenhoe at mail dot ru | Date: | Tue, 29 Jun 2004 15:40:49 +0000 |
| Subject: | note 43661 added to ref.xslt | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-72116@lists.php.net to get a copy of this message | ||
Hello, I'm about Daniel Unterberger example:
I think, it is better to use processing instructions instead of
tags (<php:eval>), because processing instructions are better
corresponding to xml concept. My variant of code:
<code>
// This is a fragment :)
$xml = preg_replace_callback("|<\?(.*)\?>|UsS","piHandler",
implode("",file($currentPage['LOCAL_PATH'].'/'.
$currentPage['FILE']));
// This is a function which handle occurences of processing instructions
function piHandler($matches)
{
/*
The feature is: you can also use other languages, for example, you can insert '<?perl
...?>'
(and so on) into your xml code and handle it correctly, e.g. using passthru() :)
*/
$phpStart = strstr($matches[1],"php");
// Of course, here you can check for other targets too :)
if ($phpStart==false) return "";
ob_start();
eval(substr($matches[1],$phpStart+strlen("php")));
$tmp = ob_get_contents();
ob_end_clean();
return $tmp;
}
</code>
Hope, it helps you ;)
----
Manual Page -- http://www.php.net/manual/en/ref.xslt.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+43661
Delete -- http://master.php.net/manage/user-notes.php?action=delete+43661&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+43661&report=yes
Search -- http://master.php.net/manage/user-notes.php