2014. szeptember 11., csütörtök
2-nél több ágú elágazás: if, elseif...elseif, else
A szerkezet a következő:
if ( feltétel ) {
} else if ( feltétel ) {
} else {
}
pl.
<!DOCTYPE html PUBLIC
"-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
<title>Listing 5.3 An if statement That Uses else and else if</title>
</head>
<body>
<div>
<?php
$satisfied = "no";
if ( $satisfied == "very" ) {
print "We are pleased that you are happy with our service";
// register customer satisfaction in some way
} else if ( $satisfied == "no" ) {
print "We are sorry that we have not met your expectations";
// request further feedback
} else {
print "Please take a moment to rate our service";
// present pulldown
}
?>
</div>
</body>
</html>
Eredmény:
We are sorry that we have not met your expectations
Feliratkozás:
Megjegyzések küldése (Atom)
Nincsenek megjegyzések:
Megjegyzés küldése