2013-08-06 32 views
0

因此,我在这里有一个欢迎页面,其中包括一个php include标签。PHP包含标签不显示文件数据

的welcome.php

<html> 
    <head> 
     <title> Web Application</title> 

     <link rel="stylesheet" type="text/css" href="extjs/resources/css/ext-all.css"> 

     <link rel="stylesheet" type="text/css" href="css/welcome_stylesheet.css"> 

     <script type="text/javascript" src="extjs/ext-debug.js"></script> 

     <script type="text/javascript" src="welcome.js"></script> 
    </head> 
    <body id="welcome"> 
     <div id="container"> 
      <p id="welcome_page_h1">Welcome</p> 
       <div id="select_container"> 
        <?php include("stuff.php"); ?> 
       </div> 
     </div> 


    </body> 
    </html> 

这里还有你的php文件我想包括/显示。

stuff.php:

<p> Well how y'all doin? </p> 
<p> Well how y'all doin? </p> 
<p> Well how y'all doin? </p> 
<p> Well how y'all doin? </p> 

我觉得我所有的鸭子,为了在这里,但没有显示。有任何想法吗?

回答

0

尝试不带括号。

<?php include "stuff.php"; ?> 
+0

嗯,不会这样做我的好先生 –

+0

@ClayBanks,在这种情况下,希望这两个文件都在同一个目录中。 – vee

+0

他们确实在同一个目录中。一切都结构良好 –

0

我有一个名为的index.php和页我用下面的代码内页...

<?php include 'header.html'; ?> 

了header.html是在同一个目录中指数。 php

+0

很奇怪,这些似乎都没有工作。我以前做过这件事,从来没有这个问题 –

+0

它可能是你的环境或权限问题。 PHP文件是否运行? – Mike

+0

是的,我的welcome.php页面运行良好,它是不会显示的包含文件。我在我公司的电脑上,有各种许可卫士,证券等,但我觉得它不会影响这样的事情。我甚至尝试过JSTL的包括,但无济于事:( –

0

如果您将要包含的文件的文件扩展名更改为除.php之外的其他文件,它将起作用。

即:
的welcome.php

// . . . 
<div id="select_container"> 
     <?php include("stuff.txt"); ?> 
</div> 

stuff.txt

<p> Well how y'all doin? </p> 
<p> Well how y'all doin? </p> 
<p> Well how y'all doin? </p> 
+0

这也没有奏效,我'我害怕 –

0

一定要检查拼写,并在同一目录您的index.php的welcome.php

如果一切都可以,你可以检查它使用这个si mple代码:

<?php 
    echo ((include "index.php") == "OK") ? "OK" : "FAILED"; 
?> 

或者使用此代码

<?php 
function get_file_content($filename) { 
    if (is_file($filename)) { 
     ob_start(); 
     include $filename; 
     return ob_get_clean(); 
    } else { 
     ob_clean(); 
     trigger_error("The file {$filename} was not found"); 
    } 
} 

echo get_file_content("index.php"); 
?> 
0

我有同样的问题,并意识到这是一个PHP代码行,我忘了分号结束。

我如何检查是从包含的文件中慢慢删除代码块,我认为这可能会影响代码并运行,直到我可以缩小源代码。