我有三个php文件:
我有:
<?php
function get_header()
{
echo "<header class=\"header\">";
echo "<div class=\"banniere\">";
echo "<a href=\"accueil.php\"><img src=\"http://localhost/e-commerce/MusicStore/img/logo.png\" alt=\"banniere\"/></a>";
echo "</div>";
echo "</header>";
}
?>
在accueil.php中:
<?php
error_reporting(E_ALL);
ini_set('display_errors', 1);
require_once('./templates/navbar.php');
require_once('./templates/header.php');
?>
<!DOCTYPE html>
<html class="html">
<head>
<link rel="stylesheet" href="./css/style.css" />
<link href="http://fonts.googleapis.com/css?family=PT+Sans+Narrow" rel="stylesheet" type="text/css" />
<meta charset="utf-8" />
<title>Music Store</title>
</head>
<body class="body_accueil"><?php
get_header();
get_navbar();
?>
<section>
<article>
<div class="new">
<a class="new_new" href="nouveaute.html">NOUVEAUTE</a>
<div class="podhd500x">
<a href="produits/159862.html"><img class="img_product" src="http://localhost/e-commerce/MusicStore/img/pedaliers/podhd500x.jpg" alt="LINE 6 POD HD500X"/></a>
<div class="description">
<a class="product_name" href="produits/159862.html">LINE 6 - POD HD500X</a>
<p>Découvrez le nouveau POD HD500X!</p>
<a href="http://localhost/e-commerce/MusicStore/templates/line6.html"><img src="http://localhost/e-commerce/MusicStore/img/marques/line6.jpg" alt="LINE 6"/></a>
<p><span class="prix">498.00€</span></p>
</div>
</div>
<div class="molotov">
<a href="produits/136803.html"><img class="img_product" src="http://localhost/e-commerce/MusicStore/img/pedales/eagletone%20molotov.jpg" alt="EAGLETONE MOLOTOV"/></a>
<div class="description">
<a class="product_name" href="produits/136803.html">EAGLETONE - MOLOTOV</a>
<p>Nouvelle pédale à distortion de chez EAGLETONE! Procurez-vous un son extra saturé!</p>
<a href="http://localhost/e-commerce/MusicStore/templates/eagletone.html"><img src="http://localhost/e-commerce/MusicStore/img/marques/eagletone.jpg" alt="EAGLETONE"/></a>
<p><span class="prix">39.00€</span></p>
</div>
</div>
<div class="microcube">
<a href="produits/164183.html"><img class="img_product" src="http://localhost/e-commerce/MusicStore/img/amplificateurs/rolandmicrocubegxw.jpg" alt="ROLAND MICRO CUBE GXW BLANC"/></a>
<div class="description">
<a class="product_name" href="produits/164183.html">ROLAND - MICRO CUBE GXW BLANC</a>
<p>Découvrez chez ROLAND les nouveaux modèles micro cube. Rapport qualité prix garantie!</p>
<a href="http://localhost/e-commerce/MusicStore/templates/roland.html"><img src="http://localhost/e-commerce/MusicStore/img/marques/roland.jpg" alt="ROLAND"/></a>
<p><span class="prix">129.00€</span></p>
</div>
</div>
<div class="evhwhite">
<a href="produits/151709.html"><img class="img_product" src="http://localhost/e-commerce/MusicStore/img/guitares/evh/evhwhite.jpg" alt="EVH STRIPE SERIES BLANC NOIR"/></a>
<div class="description">
<a class="product_name" href="produits/151709.html">EVH - STRIPE SERIES BLANC/NOIR</a>
<p>La nouvelle gamme EVH, offre de superbe guitares pour pas cher!</p>
<a href="http://localhost/e-commerce/MusicStore/templates/roland.html"><img src="http://localhost/e-commerce/MusicStore/img/marques/evh.jpg" alt="EVH"/></a>
<p><span class="prix">588.00€</span></p>
</div>
</div>
</div> <!-- END DIV NEW ARTICLE -->
</article> <!-- END ARTICLE -->
<article>
<div class="top">
<a class="top_top" href="pages/topvente.html">MEILLEURS VENTES</a>
<div class="vente">
<a href="produits/68102.html"><img class="img_guitare" src="http://localhost/e-commerce/MusicStore/img/guitares/ltd/ltdalexi600.jpg" alt="LTD ALEXI600 BLACKY SIGNATURE"/></a>
<a href="produits/121546.html"><img class="img_p" src="http://localhost/e-commerce/MusicStore/img/amplificateurs/orangedarkterror.jpg" alt="ORANGE DARK TERROR"/></a>
<a href="produits/126222.html"><img class="img_guitare" src="http://localhost/e-commerce/MusicStore/img/guitares/ibanez/s5470q.jpg" alt="IBANEZ PRESTIGE S5470Q"/></a>
<a href="produits/19491.html"><img class="img_p" src="http://localhost/e-commerce/MusicStore/img/accessoires/fastfret.jpg" alt="FAST FRET"/></a>
<a href="produits/125415.html"><img class="img_p" src="http://localhost/e-commerce/MusicStore/img/accessoires/eagletonemediato.jpg" alt="EAGLETONE MEDIATOR SET"/></a>
<a href="produits/163240.html"><img class="img_p" src="http://localhost/e-commerce/MusicStore/img/jeux/rocksmith2014ps3.jpg" alt="ROCKSMITH 2014 PS3"/></a>
<a href="produits/86268.html"><img class="img_p" src="http://localhost/e-commerce/MusicStore/img/partitions/megadeth%20countdown%20to%20extinction.jpg" alt="MEGADETH : COUNTDOWN TO EXTINCTION"/></a>
<a href="produits/66588.html"><img class="img_p" src="http://localhost/e-commerce/MusicStore/img/partitions/little%20black%20book%20of%20metal%20hits.jpg" alt="LITTLE BLACK BOOK OF METAL HITS"/></a>
<a href="produits/164183.html"><img class="img_p" src="http://localhost/e-commerce/MusicStore/img/amplificateurs/rolandmicrocubegxw.jpg" alt="ROLAND MICRO CUBE"/></a>
<a href="produits/159501.html"><img class="img_torpedo" src="http://localhost/e-commerce/MusicStore/img/pedales/torpedocab.jpg" alt="TORPEDO CAB"/></a>
<a href="nouveaute.html" class="suivant">Suivant >></a>
</div>
</div> <!-- END TOP ARTICLE -->
</article>
</section> <!-- END SECTION -->
<footer class="footer">
<div class="bloc1">
<h3><a href="contact.html">Envie de nous contacter?</a></h3>
<p>Conseil et commande au téléphone :<br />du lundi au vendredi de 9h à 20h, le samedi de 10h à 19h.</p>
<p>France métropolitaine<br /><strong class="numero">01 48 05 86 12</strong><br />Appel gratuit depuis un poste fixe.</p>
</div>
<div class="bloc2">
<h3>Horaires</h3>
<p>Ouvert du lundi au samedi de 9h à 21h non-stop.</p><p><em>1 Avenue Malanco<br />75001 Paris.<br />Station Malanco, métro ligne 12.</em></p>
</div>
<div class="bloc3">
<h3>Informations utiles!</h3>
<ul>
<li><a href="nouveaute.html" title="Nouveauté">Nouveauté</a></li>
<li><a href="nous.html" title="Qui sommes nous?">Qui sommes nous?</a></li>
<li><a href="condition.html" title="Conditions générales de vente">Conditions générales de vente</a></li>
</ul>
</div>
</footer> <!-- END FOOTER -->
</body> <!-- END BODY -->
</html>
当我去accueil.php时,我的标题有网站的标识和导航栏,但是当我检查元素时,我有这些东西:
[Screenshot] removed because it contains offensive language
它似乎是由我的get_header()生成的;在回声之前......当我在我的broswer上删除字符串时,我的徽标位于页面顶部,就像我没有功能一样。所以这些字符串有一个底部..
你对这个错误有什么看法吗?
更新navbar.php:
<?php
function get_navbar()
{
echo "<nav class=\"menu\">
<div class=\"block_menu\">
<ul class=\"niveau1\">
<li class=\"border2\"><a href=\"accueil.html\"><strong class=\"accueil\">Accueil</strong></a></li>
<li class=\"border\"><a href=\"nouveaute.html\"><strong class=\"nouveaute\">Nouveauté</strong></a></li>
<li class=\"border\">Guitares
<ul class=\"niveau2\">
<li class=\"border3\"><a href=\"accessoires.html\">Accessoires guitares</a>
<ul class=\"niveau3\">
<li><a href=\"accordeurs.html\">Accordeurs</a></li>
<li><a href=\"cables.html\">Cables</a></li>
<li><a href=\"cordes.html\">Cordes</a></li>
<li><a href=\"mediators.html\">Médiators</a></li>
<li><a href=\"micros.html\">Micros guitare</a></li>
<li><a href=\"pieces.html\">Pièces détachées</a></li>
<li><a href=\"piles.html\">Piles</a></li>
<li><a href=\"entretiens.html\">Produits d'entretien</a></li>
<li><a href=\"sangles.html\">Sangles guitare</a></li>
<li><a href=\"stands.html\">Stands guitare</a></li>
</ul>
</li>
<li class=\"border3\"><a href=\"amplis_et_effets.html\">Amplis et effets</a>
<ul class=\"niveau4\">
<li><a href=\"ampli.html\">Ampli</a></li>
<li><a href=\"effets.hmtl\">Effets</a></li>
</ul>
</li>
<li class=\"border3\"><a href=\"guitares.html\">Guitares électriques</a>
<ul class=\"niveau5\">
<li><a href=\"customshop.html\">Custom Shop ESP</a></li>
<li><a href=\"8cordes.html\">8 Cordes</a></li>
<li><a href=\"7cordes.html\">7 Cordes</a></li>
<li><a href=\"metal.html\">Métal</a></li>
</ul>
</li>
</ul>
</li>
<li class=\"border3\"><a href=\"jeux.html\">Jeux video</a>
<ul class=\"niveau6\">
<li><a href=\"rocksmith12.html\">Rocksmith</a></li>
<li><a href=\"rocksmith14.html\">Rocksmith 2014</a></li>
<li><a href=\"bandfuse.html\">BandFuse: Rock Legends</a></li>
</ul>
</li>
<li class=\"border3\"><a href=\"partitions.html\">Partitions</a>
<ul class=\"niveau7\">
<li><a href=\"tab_metal.html\">Partitions Metal</a></li>
<li><a href=\"tab_rock.html\">Partitions Rock</a></li>
<li><a href=\"tab_classique.html\">Partitions Classique</a></li>
</ul>
</li>
<li class=\"border\"><a href=\"marques.html\">Nos Marques</a></li>
<li class=\"border\"><a href=\"panier.html\">Panier</a></li>
<li class=\"border\"><a href=\"contact.html\">Contact</a></li>
</ul>
</div>
</nav>";
}
?>
所以,我在<!DOCTYPE html>
之前添加了所有'require',如果我有<?php after <body>
,我仍然有相同的奇怪空格..
NEW SCREENSHOT:screen
答案 0 :(得分:2)
将body标记放在PHP open标记旁边。所以改变:
<body class="body_accueil">
<?php
到
<body class="body_accueil"><?php
那些东西可能会消失。但你可以简单地忽略那些东西。它不会造成任何伤害。
答案 1 :(得分:0)
您直接include
(&#34; require_once
)html body
中的php文件导航栏。
因此,您的 navbar.php
声明之前的<?php
之前可能有一些空行。请检查一下,如果删除它们。另外,我建议在自己的<?php ... ?>
- Block中的文件顶部写下所有包含和要求。
如果这对您没有帮助,请提供所有文件来分析您的问题。