Executing HTML-PHP code from variables
The problem is:
I have html-php codes stored in mysql as strings... I query mysql and i obtain some variables like these:
$str_phpcode1 = "<div><?php echo "Hello world"; ?></div>";
$str_phpcode2 = "<span><?php func_loan(); ?></span>";
...
Obviously if I write
echo $str_phpcode1; or echo $str_phpcode2;
the strings will be printed as text and the "echo" and "func_loan()" are not executed as php code.
Is there a solution?
Thank you
Resolved:
eval("?>".$str_phpcode1."<?php ");
The problem is:
I have html-php codes stored in mysql as strings... I query mysql and i obtain some variables like these:
$str_phpcode1 = "<div><?php echo "Hello world"; ?></div>";
$str_phpcode2 = "<span><?php func_loan(); ?></span>";
...
Obviously if I write
echo $str_phpcode1; or echo $str_phpcode2;
the strings will be printed as text and the "echo" and "func_loan()" are not executed as php code.
Is there a solution?
Thank you
Resolved:
eval("?>".$str_phpcode1."<?php ");





