對於例>內容=樹返回的特殊內容,以樹建立一個屬性是否
含量爲>的index.php內容=樹
<?php
if (<?= $_GET['content'] ?> == tree) {
echo "text here";
}
else {
echo "nothing to see here";
}
?>
對於例>內容=樹返回的特殊內容,以樹建立一個屬性是否
含量爲>的index.php內容=樹
<?php
if (<?= $_GET['content'] ?> == tree) {
echo "text here";
}
else {
echo "nothing to see here";
}
?>
首先,我建議你檢查的PHP的手動功能和其他的PHP代碼,這裏有一個例子的,如果/ ELSEIF/else語句:link
現在,在你的代碼,你這樣做:if (<?= $_GET['content'] ?> == tree) {
注意你怎麼叫php echo <?= $_GET['content'] ?> == tree
作爲一個條件,首先出現錯誤,因爲你不能調用php作爲條件,更不用說回聲了。 你這是怎麼應該寫的代碼:
<?php
if ($_GET['content'] == 'tree') {
echo "text here";
}
else {
echo "nothing to see here";
}
?>
請看看我給你的鏈接。
搞掂:
<?php
if (isset($_GET['content']) && $_GET['content'] == 'tree') {
echo "text here";
}
else {
echo "nothing to see here";
}
?>
倍數:
<?php
if (isset($_GET['content']) && in_array($_GET['content'], array('tree', 'bird', 'fish', 'taco'))) {
echo "text here";
}
else {
echo "nothing to see here";
}
?>
刪除此標籤:''=' and '?>也把像' 「樹」 引號''tree'是 – Rizier123 2014-12-06 16:08:51
它的JavaScript或PHP? – GolezTrol 2014-12-06 16:10:39