使用下面的语法,这行代码出现错误。但是,如果我将代码行从elseif
语句更改为if
语句,我不会收到错误消息。怎么了?
错误行:elseif($weight <= 5000)
我所有的 PHP 代码:
if ($delivery == 'one') {
if ($weight <= 1000)
{
if (royal_s) {
$first = 'Royal Mail Small Parcels';
$first_p = '3.00';
$second = 'Parcelforce 24';
$second_p = '15.96';
} elseif (royal_m) {
$first = 'Royal Mail Medium Parcels';
$first_p = '5.65';
$second = 'Parcelforce 24';
$second_p = '15.96';
} elseif (parcelforce) {
$first = 'Parcelforce 24';
$first_p = '15.96';
} else {
sorry;
}
}
elseif ($weight <= 2000)
{
if (royal_s){
$first = 'Royal Mail Small Parcels';
$first_p = '6.85';
$second = 'Parcelforce 24';
$second_p = '15.96';
} elseif(royal_m) {
$first = 'Royal Mail Medium Parcels';
$first_p = '8.90';
$second = 'Parcelforce 24';
$second_p = '15.96';
}
elseif(parcelforce){
$first = 'Parcelforce 24';
$first_p = '15.96';
} else {
sorry;
}
elseif($weight <= 5000)
{
if (royal_m) {
$first = 'Royal Mail Medium Parcels';
$first_p = '15.10';
$second = 'Parcelforce 24';
$second_p = '16.92';
} elseif(parcelforce){
$first = 'Parcelforce 24';
$first_p = '15.96';
} else {
sorry;
}
}
}
}