Dynadot — .com Registration $8.99

[Resolved] Executing HTML-PHP code from variables

Spaceship Spaceship
Watch

mignolo

Established Member
Impact
10
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 ");
 
0
•••
The views expressed on this page by users and staff are their own, not those of NamePros.
Unstoppable DomainsUnstoppable Domains

We're social

Unstoppable Domains
Domain Recover
NameMaxi - Your Domain Has Buyers
  • The sidebar remains visible by scrolling at a speed relative to the page’s height.
Back