我試圖用if語句獲得一個包含3個部分的頁面。請看代碼,並幫助我。
如果你不告訴我學習這個或那個,我會很高興,因爲我正在做這件事。
<?php
if (isset($_GET['part'])&&!empty($_GET['part'])){
if($_GET['part'] = '1'){
## Part 1
## Some content
echo '1';
}else if($_GET['part'] = '2'){
## part 2
## Some content
echo '2';
}else if($_GET['part'] = '3'){
## Part 3
## Some content
echo '3';
}
}else{
header('Location: index.php?part=1');
}
?>
在條件相等性比較應該是''==不'='。所以你應該有'$ _GET ['part'] =='value''。 – Bogdan 2014-10-12 12:00:31
,而不是一個等號,用於分配使用兩個等號作比較! – goseo 2014-10-12 12:01:47
謝謝,這是幫助:) – Magnus 2014-10-12 12:12:42