.
.
IF
:
if ()
_
:
if ($a >
$b)
print "a , b";
if ($a >
$b) {
print "a ,
b";
$b = $a;
}
ELSE
:
if ($a > $b)
{
print "a , b";
} else
{
print "a ,
b";
}
elseif
. ,
IF ELSE
:
if ($a > $b)
{
print "a is bigger than b";
} elseif
($a == $b) {
print "a is equal to
b";
} else {
print "a is smaller than
b";
}
if(): ... endif;
. ,
, IF
, ,
':' ENDIF;
:
<?php if ($a==5): ?>
A = 5
<?php endif; ?>
ELSEIF
if ($a == 5):
print "a equals 5";
print "...";
elseif ($a == 6):
print "a equals 6";
print "!!!";
else:
print "a is neither 5 nor 6";
endif;
WHILE
:
while (): _ ... endwhile;
:
$i = 1;
while ($i <= 10) {
print $i++;
}
do.. while
- - , .
,
. :
do _ while
();
FOR
- C++. :
for (1; 2; 3)
_
- . PHP . :
for (1; 2; 3):
_; ...; endfor;
, .
break
.
(for, while, do.. while)
. :
$i = 0;
while ($i < 10) {
if ($arr[$i] == "stop") {
break;
}
$i++;
}
continue
.
_
. :
while () {
if (2)
continue;
;
};
,
continue:
while () {
if (!2)
;
};
switch
.
, .
:
if ($i == 0) {
print "i 0";
} else
if ($i == 1) {
print "i 1";
} else
if ($i == 2) {
print "i 2";
} else
print " "
, -
.
, ,
:
switch ($i) {
case 0:
print "i 0";
break;
case 1:
print "i 1";
break;
case 2:
print "i 2";
break;
default:
print " "
}
.
break case 1:,
, $1
, $I 1 ,
break;
switch
require
- #include
C++. , ,
. , require
- ,
"" .
:
require 'header.inc';
include
:
include 'func.inc';
,
(func.inc ) ,
. .
func.inc
. ,
include 'func.inc',
, - - ,
func.inc
. include require
, ,
.