2011-10-08 39 views
1

我有一个PHP页面Read.php回应另一个PHP文件的内容,test.php.test.php包含一些PHP代码,但这些代码不在Read.php中处理。他们被照原样复制。为什么PHP代码没有被处理?

Read.php

<?php 

    $text = 1; 
    if ($text == 1){ 
     $file = file_get_Contents("test.php"); 
     echo $file; 
    } 
?> 

test.php的

<html> 
    <body> 
     <p>Text 
      <?php echo "Manish"; echo $text;> 
     </p> 
    </body> 
</html> 

来源Read.php

的代码
<html> 
    <body> 
     <p>Text 
      <?php echo "Manish"; echo $text;> 
     </p> 
    </body> 
</html> 

如何让我这个PHP代码的过程?

回答

2
<?php 

    $text = 1; 
    if ($text == 1){ 
     include('test.php'); 
    } 
?> 
1

从Web服务器(http://...)中检索它,而不是从文件系统中检索它。 PHP只在Web服务器处理它时才被处理。

+0

当然,从技术上'包括()'ING或'需要()'荷兰国际集团的文件也将导致这里类似的行为。 – Amber

+0

公平点。这两个文件都通过PHP引擎。 –

2

Read.php

<?php 

$text = 1; 
if($text == 1){ 
    include 'test.php'; 
} 

?>