开发者

How to echo out php code that will execute?

I am making a website and would want to do the following, but I have no idea how: echo out HTML code with PHP code, so the PHP code executes. I read the file and echo it, but the PHP code is just a string of text and does not execute.

For example:

[a website file dude.php]

<html>
<?php
echo "dude";
?>
</html>

[another website file, that tries to echo out dude.php file, with the PHP code executed]

<?php
$pathToFile = 'dude.php';
$myFile = fopen($pathToFile, 'r');
$theData = fread($myFile, filesize($pathToFile));
echo $theData;
fclose($myFile);
?>

But all I get, is dude.php echoed out with the PHP code not executed.

I do not understand why, maybe there is something with the "ec开发者_如何学Goho" command...

I hope that this was clear enough for people to understand. I really don't know any other way to explain it.


You're looking for the include statement.


Evaluate string code wiht eval($somePhpCode). -Documentation- But maybe you want to use include as well.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜