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 "echo" command...
I hope that this was clear enough for people to understand. I really don't know any other way to explain it.
您正在寻找include
声明。
Evaluate string code wiht eval($somePhpCode). -Documentation- But maybe you want to use include as well.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.