note 95478 deleted from function.eval by peehaa
| From: | peehaa@php.net | Date: | Mon, 09 Dec 2013 12:00:44 +0000 |
| Subject: | note 95478 deleted from function.eval by peehaa | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-197875@lists.php.net to get a copy of this message | ||
Note Submitter: ajo at NO dot SPAM dot mydevnull dot net
----
Inspired from the users microvalen at NOSPAM dot microvalen dot com and javis, i combined their
notes and came up with a very simple "template engine", for testing purposes (to save the
time and trouble of downloading and including a real template engine like the Smarty):
<?php
$var = 'dynamic content';
echo eval('?>' . file_get_contents('template.phtml') . '<?');
?>
and the template.phtml:
<html>
<head>
<!-- ... -->
</head>
<body>
<!-- ... -->
<?=$var?>
<!-- ... -->
</body>
</html>
This is something i use a lot (specially when studying new PHP Libraries or trying new jQuery
plugins) and i think it might help others too.