回声'
' PHP当我这样做时:
echo '<li></li>';
在
内的 php 中,它会破坏 php 的其余部分并导致 '; ?>
显示在我的网站上。我正在尝试列出日记条目,以前已经做过很多次了,但现在似乎不起作用,这很奇怪。
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<?php
mysql_connect("localhost", "root");
mysql_select_db("lunatic");
?>
<title>Lunatic Cowboys - Gæstebog</title>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
<link rel="stylesheet" href="css/reset.css" />
<link rel="stylesheet" href="css/text.css" />
<link rel="stylesheet" href="css/960.css" />
<link rel="stylesheet" href="css/style.css" />
</head>
<body>
<div id="headercont" class="container_12">
<div id="header" class="grid_12"></div>
<div id="navigation" class="grid_12">
<ul>
<li><a href="index.html">Forside</a></li><li> -</li>
<li><a href="historie.html">Historie</a></li><li> -</li>
<li><a href="klubben.html">Klubben</a></li><li> -</li>
<li><a href="vedtaegter.html">Vedtægter</a></li><li> -</li>
<li><a href="dansetider.html">Dansetider</a></li><li> -</li>
<li><a href="instruktoer.html">Instruktør</a></li><li> -</li>
<li><a href="kalender.html">Kalender</a></li><li> -</li>
<li><a href="galleri.html">Galleri</a></li><li> -</li>
<li><a href="http://lunaticcowboys.blogspot.com/" target="_blank">Blog</a></li><li> -</li>
<li><a href="gaestebog.html">Gæstebog</a></li><li> -</li>
<li><a href="links.html">Links</a></li><li> -</li>
<li><a href="kontakt.html">Kontakt</a></li>
</ul>
</div>
</div>
<div id="contcont" class="container_12">
<div id="content" class="grid_12">
<h1 id="overskrift">Gæstebog</h1>
</div>
<div id="guestbook" class="grid_7">
<h2>Se hilsner</h2>
<ul>
<?php
$eQuery = mysql_query("SELECT * FROM guestbook");
while($entries = mysql_fetch_assoc($eQuery)){
echo "<li></li>";
}
?>
</ul>
</div>
<div id="add" class="grid_5">
<h2>Skriv en hilsen</h2>
<form id="guestbookform" method="post" action="add.html">
<fieldset>
<label for="name">Navn: </label>
<input type="text" id="name" name="name"/><br />
<label for="email">Email: </label>
<input type="text" id="email" name="email"/><br />
<label for="klub">Klub: </label>
<input type="text" id="klub" name="klub"/><br />
<label for="msg">Hilsen: </label>
<textarea name="msg" id="msg" rows="8" cols="39" onfocus="this.value=null;">Skriv din hilsen her</textarea><br />
<input type="button" onClick="javascript:addGreeting()" value="Send hilsen!" />
</fieldset>
</form>
</div>
<div id="copyright" class="grid_12">
<p>2011© Copyright Lunatic Cowboys<br />Udvikling og design af <a href="http://alexkotsc.co.cc">Alexander Kotschenreuther</a></p>
</div>
</div>
<script language="javascript" type="text/javascript">
function addGreeting(){
var aReq;
try{
// Opera 8.0+, Firefox, Safari
aReq= new XMLHttpRequest();
} catch (e){
// Internet Explorer Browsers
try{
aReq = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
try{
aReq = new ActiveXObject("Microsoft.XMLHTTP");
} catch (e){
// Something went wrong
alert("Your browser broke!");
return false;
}
}
}
var name = document.getElementById('name').value;
var email = document.getElementById('email').value;
var klub = document.getElementById('klub').value;
var msg = document.getElementById('msg').value;
aReq.onreadystatechange = function(){
if(aReq.readyState == 4){
document.getElementById('add').innerHTML = aReq.responseText;
}
}
aReq.open('GET', 'add.php' + '?name=' + name + '&email=' + email + '&klub=' + klub + '&msg=' + msg, true);
aReq.send(null);
}
如您所见,没有未打开的标签。我真的不明白,我已经这样做了很多次了,从来没有遇到过问题。可能是什么原因造成的?
屏幕截图:https://i.sstatic.net/UH68S.png
Google Chrome 开发者工具屏幕截图:https://i.sstatic.net/0KdOm.png
就像“渲染”时的 < ?php 标签被视为 < !--喜欢评论。
When I do this:
echo '<li></li>';
in php inside a <ul>
, it breaks the rest of the php and results in '; ?>
showing up on my site.
I'm trying to list journal entries and I've done it many times before, but it just doesn't seem to work now, which is very strange.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<?php
mysql_connect("localhost", "root");
mysql_select_db("lunatic");
?>
<title>Lunatic Cowboys - Gæstebog</title>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
<link rel="stylesheet" href="css/reset.css" />
<link rel="stylesheet" href="css/text.css" />
<link rel="stylesheet" href="css/960.css" />
<link rel="stylesheet" href="css/style.css" />
</head>
<body>
<div id="headercont" class="container_12">
<div id="header" class="grid_12"></div>
<div id="navigation" class="grid_12">
<ul>
<li><a href="index.html">Forside</a></li><li> -</li>
<li><a href="historie.html">Historie</a></li><li> -</li>
<li><a href="klubben.html">Klubben</a></li><li> -</li>
<li><a href="vedtaegter.html">Vedtægter</a></li><li> -</li>
<li><a href="dansetider.html">Dansetider</a></li><li> -</li>
<li><a href="instruktoer.html">Instruktør</a></li><li> -</li>
<li><a href="kalender.html">Kalender</a></li><li> -</li>
<li><a href="galleri.html">Galleri</a></li><li> -</li>
<li><a href="http://lunaticcowboys.blogspot.com/" target="_blank">Blog</a></li><li> -</li>
<li><a href="gaestebog.html">Gæstebog</a></li><li> -</li>
<li><a href="links.html">Links</a></li><li> -</li>
<li><a href="kontakt.html">Kontakt</a></li>
</ul>
</div>
</div>
<div id="contcont" class="container_12">
<div id="content" class="grid_12">
<h1 id="overskrift">Gæstebog</h1>
</div>
<div id="guestbook" class="grid_7">
<h2>Se hilsner</h2>
<ul>
<?php
$eQuery = mysql_query("SELECT * FROM guestbook");
while($entries = mysql_fetch_assoc($eQuery)){
echo "<li></li>";
}
?>
</ul>
</div>
<div id="add" class="grid_5">
<h2>Skriv en hilsen</h2>
<form id="guestbookform" method="post" action="add.html">
<fieldset>
<label for="name">Navn: </label>
<input type="text" id="name" name="name"/><br />
<label for="email">Email: </label>
<input type="text" id="email" name="email"/><br />
<label for="klub">Klub: </label>
<input type="text" id="klub" name="klub"/><br />
<label for="msg">Hilsen: </label>
<textarea name="msg" id="msg" rows="8" cols="39" onfocus="this.value=null;">Skriv din hilsen her</textarea><br />
<input type="button" onClick="javascript:addGreeting()" value="Send hilsen!" />
</fieldset>
</form>
</div>
<div id="copyright" class="grid_12">
<p>2011© Copyright Lunatic Cowboys<br />Udvikling og design af <a href="http://alexkotsc.co.cc">Alexander Kotschenreuther</a></p>
</div>
</div>
<script language="javascript" type="text/javascript">
function addGreeting(){
var aReq;
try{
// Opera 8.0+, Firefox, Safari
aReq= new XMLHttpRequest();
} catch (e){
// Internet Explorer Browsers
try{
aReq = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
try{
aReq = new ActiveXObject("Microsoft.XMLHTTP");
} catch (e){
// Something went wrong
alert("Your browser broke!");
return false;
}
}
}
var name = document.getElementById('name').value;
var email = document.getElementById('email').value;
var klub = document.getElementById('klub').value;
var msg = document.getElementById('msg').value;
aReq.onreadystatechange = function(){
if(aReq.readyState == 4){
document.getElementById('add').innerHTML = aReq.responseText;
}
}
aReq.open('GET', 'add.php' + '?name=' + name + '&email=' + email + '&klub=' + klub + '&msg=' + msg, true);
aReq.send(null);
}