Alternative to eval for dynamically evaluating mixed content strings (html + php) within php script -
let's right it.
index.php
<?php ... $url = "www.google.com"; $val = "is php better perl?"; $file = file_get_contents("mixedcontent.txt"); print eval("?>" . $file . "<?"); ... ?>
mixedcontent.txt
<html> ... <form action="<?php echo $url; ?>"> <input id="q" type="text" value="<?php echo $val; ?>"/> </form> ... </html>
the 2 files stubs , required separate, due limitations of commercial software on dependent.
now, realize eval viewed many last resort , suggest redesign, since eval can security risk. there alternative using eval dynamically evaluating mixed content (i.e. html + php)? somehow utilize create_function or call_user_func?
thank you.
update
based on recommendations in comments , answers sections use include particular type of example, have modified code:
index.php
index.php
<?php ... $url = "www.google.com"; $val = "is php better perl?"; include("mixedcontent.txt"); ... ?>
that looks works well. thank all.
i agree jared, include
way go, if don't want use or if not working you. can try following, think better alternative
Comments
Post a Comment