Can you execute a php code in a variable? from the database without it showing the code but acually DOING the code
executea php code in a variable
Started by b3nji, Nov 21 2005 06:54 PM
5 replies to this topic
#1
Posted 21 November 2005 - 06:54 PM
#2
Posted 21 November 2005 - 09:27 PM
if you use things like:
yes. And normally no. When you get a variable, it can be executed as PHP code, but isnt meant to, because it is echoed. But that above doesnt echo, just places it out.
Or use the return function, I guess.
<html> <body> blah <?=$include?> </body> </html>
yes. And normally no. When you get a variable, it can be executed as PHP code, but isnt meant to, because it is echoed. But that above doesnt echo, just places it out.
#3
Posted 21 November 2005 - 09:37 PM
Actually, i believe the eval() function is what he is looking for.
From what i know of your method, that simply echo's the code, and doesn't "run" it.
From what i know of your method, that simply echo's the code, and doesn't "run" it.
Edited by rc69, 21 November 2005 - 09:38 PM.
#4
Posted 22 November 2005 - 01:20 AM
Are you looking to do something like
<?php $code = '<?php echo "hey!"; ?>': echo $code; ?>If so, do what rc69 said and use echo eval($code);
#5
Posted 22 November 2005 - 04:59 PM
Note, if you use the open/closing php tag's, then you'll want to close your php tag before "evaling" the code.
Example
Example
<?
$code = '<? echo "blah"; ?>';
eval('?>'.$code);
?>
#6
Posted 22 November 2005 - 05:15 PM
Yeah what he said, lol
1 user(s) are reading this topic
0 members, 1 guests, 0 anonymous users
