Jump to content

[SOLVED] question about elseif statements....


dsaba

Recommended Posts

it will just find 1

try it


<html>
<head>

<title>Sample</title>
</head>

<body>

<?


$char1 = "A";
$char2 = "B";
$char3 = "C";
$char4 = "D";

if ($char1 == "B")
{
print "char 1";
}
else if ($char2 == "B")
{
print "char 2";
} 

else if ($char3 = "C")
{
print "char 3";
}

else { print "none"; }


?>
</body>
</html>

 

Drew

correct me if i am wrong but it will only continue if the statement is false.

 

so:

 

$a = 1;
$b = 4;

if($a == 1){
echo "A is 1<br>";
}elseif($a == 2){
echo "A is 2<br>";
}elseif($b == 4){
echo "B is 4";
}

 

above would only echo A is 1.

i think it would have to be like this

<?
if (BLAH) {
} else if (BLAH) {
else if (BLAH) {
}
else if (BLAH) {
}else if (BLAH) {
}
} else if (BLAH) {
}
?>

you would but a bunch of different else if statements in side of one of the else if state ments

i probly didn't show it very well

but u should get what i mean

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.