2016-06-01 12 views
0

私のheader.phpファイルとfooter.phpファイルは、index.htmlファイルから取得されません。私はStackoverflowを検索し、<?php include("header.php"); ?>または$("#header").load("header.html");のような異なるバリエーションをたどってきましたが、それでも動作しません。私のコードは以下のように、私が間違っていることを誰かアドバイスできますか?htmlサイトのヘッダ&フッタPHPコールが機能していません

header.phpの

<!DOCTYPE html> 
<html lang="en"> 
    <head> 
    <meta charset="utf-8"> 
    <meta http-equiv="X-UA-Compatible" content="IE=edge"> 
    <meta name="viewport" content="width=device-width, initial-scale=1"> 
    <!-- The above 3 meta tags *must* come first in the head; any other head content must come *after* these tags --> 
    <title>aaaa</title> 
    <meta name="description" content="aaaa."> 
    <link rel='shortcut icon' href='myfavicon.ico' type='image/x-icon'/ > 

    <!-- Bootstrap --> 
    <link href="css/bootstrap.min.css" rel="stylesheet"> 

    <!-- Custom CSS --> 
    <link href="css/custom.css" rel="stylesheet"> 
    <!-- Custom Fonts --> 
    <link href='https://fonts.googleapis.com/css?family=Source+Sans+Pro:400,300,700' rel='stylesheet' type='text/css'> 
    <!-- Font Awesome --> 
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.6.1/css/font-awesome.min.css"> 

    <!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries --> 
    <!-- WARNING: Respond.js doesn't work if you view the page via file:// --> 
    <!--[if lt IE 9]> 
     <script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script> 
     <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script> 
    <![endif]--> 
    </head> 

<header> 
     <!-- HEADER --> 
    <nav class="navbar navbar-default"> 
     <div class="container-fluid"> 
      <div class="navbar-header"> 
       <button type="button" class="navbar-toggle collapsed" 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.html"> 
      <img alt="aaaa" src="images/aa.png" height="30px"> 
     </a> 
     </div>  
     </div><!--END CONTAINER FLUID--> 
    </nav> 

Index.htmlと

<?php include("header.php"); ?> 
<div class="container-fluid"> 
      <div class="row feature"> 
       <img src="images/Homepage%20Banner.jpg" class="img-responsive" alt="aaaa"> 
       <div class="feature-text col-xs-12 col-md-8 col-lg-6 col-md-offset-2 col-lg-offset-3"> 
        <p>aaaaa</p> 
       </div><!--END FEATURE TXT--> 
      </div><!--END ROW FEATURES--> 
+0

コンソールで表示されているエラーは何ですか? 'header.php'はindexと同じ場所にありますか? 'index.html'を' index.php'に変更してください。 load( "header.html"); '、' $( "#header")でなければなりません。 – Thamilan

答えて

0

の代わりに、index.htmlを変更index.phpを。 私たちは他のPHPファイルを含めることができるだけのPHPファイルを使用して。

1

PHPコードは、拡張子が.phpのファイルにあります。 Header.phpにPHPコードがない場合は、.HTML(拡張子:Header.html )なので、index.htmlの名前をindex.phpに変更してください。

0

PHPはあなたが指示しない限り、有効なPHP拡張モジュールとして認識しないため、PHPを.htmlファイルで実行することはできません。

ここで<?php include("header.php") ?>はHTMLファイルのPHPコードです。

index.htmlをindex.phpに変更する必要があります

関連する問題