我有兩個文件,如下面PHP - 的eval()問題
SomeClass.php
class SomeClass {
public function display() {
$content = file_get_contents("helloworld.php");
eval($content);
}
public function helloWorld() {
echo "hello World!";
}
}
helloworld.php
<?php
$this->helloWorld() ;
?>
<p>It's html expression</p>
正如你所看到的,我試圖執行的HelloWorld。 PHP在顯示功能。 當然,因爲html標籤被放置在顯示函數中,所以發生錯誤。
有沒有什麼好的方法可以在保留helloworld.php代碼的顯示函數中執行helloworld.php文本?
爲什麼不乾脆['require'(HTTP://www.php。淨/要求)'helloworld.php'? – icktoofay 2011-04-30 05:49:17