Click to See Complete Forum and Search --> : string problem
lincsimp
10-29-2004, 07:35 AM
Hi
I have a string like this: "<?php dosomething(); ?><html>....</html>"
How can I get it to run the php and display the html as if it were being run as a file?
Thanks Ben
you can write this string into a file (let's call it "temporary_file") and use the include instruction :
include("temporary_file");
Originally posted by lincsimp
I have a string like this: "<?php dosomething(); ?><html>....</html>"
How can I get it to run the php and display the html as if it were being run as a file?
I could be mistaken, but do you mean you have that string in a variable, and you want to execute it, as if it were actual code, without using includes on an external file? Try eval() (http://www.php.net/eval).
<?php
$var = '<?php dosomething(); ?><html>....</html>';
eval ($var);
?>
lincsimp
10-30-2004, 05:21 AM
Thanks! That was just what I was looking for