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

Your name:

Reply:


Posted by Marc Stoecklin on 06/08/05 17:24

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

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация