Include (evaluate) PHP/HTML code stored in a variable

From: Date: Wed, 08 Jun 2005 14:24:01 +0000
Subject: Include (evaluate) PHP/HTML code stored in a variable
Groups: php.general 
Request: Send a blank email to php-general+get-216624@lists.php.net to get a copy of this message
Hi all, I am trying to figure out how mixed HTML and PHP code (like one might have in a normal PHP file) can be evaluated if it is stored in a variable, e.g. obtained from a database query. Unfortunately, the ``eval'' function only accepts pure PHP code which (in addition) must not have any syntax errors. My hope is that there exists a function similar to ``include(..)'' that accepts a variable containing code. Or: is there a possibility to invoke the parser of the ``include'' function to evaluate and execute mixed PHP and HTML code? Any other suggestions? Thank you! Marc. Example : ========= ----sample HTML/PHP code stored in variable $code---- <form action="?action=<?php print(FORM_ACTION); ?>"> <input name="<?= INPUT_A ?>" type="text" value="<?php print(get_value(INPUT_A)); ?>" /> <input name="<?= INPUT_S ?>" value="Submit" /> </form> ----end sample HTML/PHP---- ----sample PHP code---- <?php // 1. build the container of a page ... // 2. access database and retrieve the content code // into $code // 3. evaluate $code, similar to include(...) ?> ----end sample PHP code----

« previous php.general (#216624) next »