parse_string() or similar functionality?
| From: | Colin Viebrock | Date: | Tue, 06 Jun 2000 15:00:58 +0000 |
| Subject: | parse_string() or similar functionality? | ||
| Groups: | php.dev | ||
| Request: | Send a blank email to php-dev+get-20329@lists.php.net to get a copy of this message | ||
How easy would it be to add something like this:
$string = 'The date is <? echo date("d-M-Y"); ?> today!';
echo $string;
$new = parse_string($string);
echo $new;
The output would be:
The date is <? echo date("d-M-Y"); ?> today!
The date is 06-06-2000 today!
Basically, can you run the PHP parser on a string that contains
PHP code? This would sort of be like include(), except that
it takes a string instead of a file, and it stores the output in
a string, instead of echo-ing it.
All attempts with eval() and preg_replace('/.../e') have proved
futile. :)
__________________________________________________________________
Colin Viebrock easyDNS Technologies
Co-Founder control your domain
http://www.easyDNS.com