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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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----

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux