2017-02-16 4 views
-1

単純なif ... else文を実行しようとしています。当初、次のように指定されました:単純なif ... else文が必要です。

<?php 
$IntVariable = 75; 
($IntVariable > 100) ? $Result = '$IntVariable is 
greater than 100' 
: $Result = '$IntVariable is less than or equal 
to 100'; 
echo "<p>$Result</p>"; 
?> 

if ... elseステートメントに変更する必要があります。これまでのところ、私が書いた:

<?php 
$IntVariable = 75; 
if ($IntVariable > 100) { 
    $Result = '$IntVariable is greater than 100'; 
    } 
    else { 
    $Result = '$IntVariable is less than or equal to 100'; 
    } 
    else { 
    echo "<p>$Result</p>"; 
} 
?> 

私はPHPには本当に新しいですあなたが持っている場合ので、私はecho $result

に再び本当に簡単... ​​

+0

2つのelse文があります。 – RSon1234

+0

多くのelse文を使用する場合は、elseifを使用する必要があります – fizzi

答えて

1

なぜelse何かが欠落している可能性がありあなたが使用できる多くの条件else if ..それ以外の場合はelse

<?php 
$IntVariable = 75; 
if ($IntVariable > 100) { 
    $Result = '$IntVariable is greater than 100'; 
    } 
    else { 
    $Result = '$IntVariable is less than or equal to 100'; 
    } 
     echo "<p>$Result</p>"; 

?>