PHP 不会在标题下方显示代码



我们建立了我们的网站,它在本地主机中显示正常,但显示这当它在线上传时。控制台中没有错误,文件排列良好。老实说,我不知道问题出在哪里,我只是假设它在代码中,因为下面包含"模板/标题.php的其他所有内容都没有显示。

这是我的索引代码示例.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>

请在您的案例中在 head 部分之后包含文件,并尝试如下

<?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>

我发现这是连接到数据库的问题。我忘了检查数据库配置。如果其他人遇到此问题,请告诉我。非常感谢所有试图提供帮助的人!非常感谢。

最新更新