【问题标题】:PHP files which I have include doesn't appear in php file我包含的 PHP 文件没有出现在 php 文件中
【发布时间】:2013-07-03 15:57:27
【问题描述】:

回答:是网络托管的问题。

这是我的代码

<!DOCTYPE html> 
<html lang="en">
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> 
        <meta name="description" lang="en" content="Test Website " /> 
        <meta name="author" content=""> 
        <link rel="stylesheet" type="text/css" href="css/style.css">
        <title</title>
    </head>
    <body>
        <section id="wrapper">
            <?php include('includes/topHeader.php'); ?>
            <?php include('includes/leftSide.php'); ?>
            <?php include('includes/middleSide.php'); ?>
            <?php include('includes/rightSide.php'); ?>
        </section>

        <?php include('includes/foot.php'); ?>
        </section>
    </body>
</html>

质疑其他php文件没有出现在主页?

为了创建它,我使用了这个网站 http://www.1stwebdesigner.com/css/how-to-create-php-website-template/

更新 查看源显示:

<section id="wrapper">

<!--?php include('../includes/topHeader.php'); ?-->
<!--?php include('../includes/leftSide.php'); ?-->
<!--?php include('../includes/middleSide.php'); ?-->
<!--?php include('../includes/rightSide.php'); ?-->

</section>

<!--?php include('../includes/foot.php'); ?-->

【问题讨论】:

  • include 换成require。我想这些文件不在您认为它们所在的目录中。
  • 你有一个没有打开的关闭“”标签。
  • @Steve 在结束的

标签: php html include


【解决方案1】:

您正在使用include 功能正确,所以请确保:

  • 您尝试包含的文件确实存在,您可以使用file_exists 函数进行测试
  • 文件中没有任何致命错误导致程序停止执行(您可以查看错误日志)
  • 您的标记格式正确(在某些情况下,当代码格式不正确时,浏览器无法正确呈现页面)

【讨论】:

    【解决方案2】:

    除了已经建议的内容外,请快速说明一下。试试

    <?php include('../includes/topHeader.php'); ?>
    <?php include('../includes/leftSide.php'); ?>
    <?php include('../includes/middleSide.php'); ?>
    <?php include('../includes/rightSide.php'); ?>
    

    我假设包含文件夹位于文件夹结构中的当前文件之上。

    【讨论】:

    • 从 Denis 链接到的教程来看,这不是文件夹结构。
    • 抱歉,我没有查看教程。
    • 不用担心。无论如何,这是个好主意,而且通常是在这种情况下进行有效的理智检查。
    • 尝试使用 firebug 调试它。检查 Net TAB 并相应地解析路径。
    • 在测试任何其他建议之前不要忘记回复&lt;?php include('includes/topHeader.php'); ?&gt;。我注意到jsfiddle.net/K7sQn 的代码仍在使用&lt;?php include('../includes/topHeader.php'); ?&gt;
    猜你喜欢
    • 1970-01-01
    • 2011-08-02
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-09-29
    • 2020-06-20
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多