note 43661 deleted from ref.xslt by tomsommer
| From: | tomsommer@php.net | Date: | Tue, 29 Jun 2004 19:11:38 +0000 |
| Subject: | note 43661 deleted from ref.xslt by tomsommer | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-72124@lists.php.net to get a copy of this message | ||
Note Submitter: ivenhoe@mail.ru
----
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 ;)