Php不显示标题下方的代码

时间:2017-01-23 09:44:15

标签: php header display

我们设置了我们的网站,它在localhost中显示正常但显示 this 当它在线上传时。控制台中没有错误,文件排列正常。老实说,我不知道问题出在哪里,我只是假设它在代码中,因为下面的其他内容包括&templates; header.php'没有显示。

以下是我的index.php

代码示例
<?php
session_start();
include 'templates/header.php';
include 'library/announcements.php';
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="description" content="Resources for the Blind, Inc. Website     2017">
<meta name="author" content="Platinum Phenomena">
<title>Resources for the Blind, Inc.</title>
<link rel="stylesheet" type="text/css" href="css/bootstrap.min.css">
<link rel="stylesheet" type="text/css" href="css/main.css">
<link rel="stylesheet" type="text/css" href="css/animate.css">
<link rel="stylesheet" type="text/css" href="css/responsive.css">


<script    src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js">
</script>
<script src="script.js"></script>
<!-- Google CDN jQuery with fallback to local -->
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"
</script>
<script>window.jQuery || document.write('<script src="js/minified/jquery-1.11.0.min.js"><\/script>')
</script>

try{
    if( !file_exists("library/announcements.php") )
    {  throw new Exception("Unable to include resources announcements");  }
    else{  require_once("library/announcements.php");  }
}catch(Exception $e){
    echo $e->getMessage();
    exit;
}
?>
<header id="header" role="banner">      
    <div class="main-nav">
        <div class="container">
            <div class="header-top">
                <div class="pull-right social-icons">
                    <a href="https://web.facebook.com/resourcesfortheblind/?fref=ts"><img src="images/fb.png"></a>
                    <a href="https://www.youtube.com/user/resourcesfortheblind"><img style="width:40px; height:40px;" src="images/yt.png"></a>
                    <a href="https://www.instagram.com/resourcesfortheblind/"><img src="images/ig.png"></a>
                    <a href="https://twitter.com/rbi_usa"><img src="images/twitter.png"></a>
                </div>
            </div>     
            <div class="row">                   
                <div class="navbar-header">
                    <button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">
                        <span class="sr-only">Toggle navigation</span>
                        <span class="icon-bar"></span>
                        <span class="icon-bar"></span>
                        <span class="icon-bar"></span>
                    </button>
                    <a class="navbar-brand" href="index.php">
                        <img class="img-responsive" src="images/logo.jpg" height="8" alt="logo">
                    </a>                    
                </div>
                <div class="collapse navbar-collapse">
                    <ul class="nav navbar-nav navbar-right">                 
                        <li class="scroll active">
                            <a href="#mainhome">Home</a>
                        </li>                    
                        <li class="scroll">
                            <a href="#activities">Activities</a>
                        </li>
                        <li class="scroll">
                            <a href="#about">About Us</a>
                        </li>
                        <li class="scroll">
                            <a href="#sponsor">Partners</a>
                        </li>
                        <li class="scroll">
                            <a href="#contact">Contact</a>
                        </li>

                    </ul>
                </div>
            </div>
        </div>
    </div>                    
</header>

2 个答案:

答案 0 :(得分:1)

请在您的案例中包含头部后面的文件,并尝试如下给出

<?php
    session_start(); 
    ?>
    <!DOCTYPE html>
    <html lang="en">
    <head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta name="description" content="Resources for the Blind, Inc. Website     2017">
    <meta name="author" content="Platinum Phenomena">
    <title>Resources for the Blind, Inc.</title>
    <link rel="stylesheet" type="text/css" href="css/bootstrap.min.css">
    <link rel="stylesheet" type="text/css" href="css/main.css">
    <link rel="stylesheet" type="text/css" href="css/animate.css">
    <link rel="stylesheet" type="text/css" href="css/responsive.css">


    <script    src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js">
    </script>
    <script src="script.js"></script>
    <!-- Google CDN jQuery with fallback to local -->
    <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"
    </script>
    <script>window.jQuery || document.write('<script src="js/minified/jquery-1.11.0.min.js"><\/script>')
    </script>

    </head>
    <body>
    <?php 

    try{
        if( !file_exists("templates/header.php") )
        {  throw new Exception("Unable to include resources header");  }
        else{  require_once("templates/header.php");  }
    }catch(Exception $e){
        echo $e->getMessage();
        exit;
    }

    try{
        if( !file_exists("library/announcements.php") )
        {  throw new Exception("Unable to include resources announcements");  }
        else{  require_once("library/announcements.php");  }
    }catch(Exception $e){
        echo $e->getMessage();
        exit;
    }
?>
    </body>
    </html>

答案 1 :(得分:1)

我发现连接数据库时出现问题。我忘了检查数据库配置。如果其他人遇到此问题,请告诉我。非常感谢那些试图帮助的人!非常感谢。