" /> Module Nice Ajax Poll
Home Theory of php

Boolean Operators

The structure of the if statement

1
echo $kol_f==($_POST['kol_f']=='Выбрать') ? '' : $_POST['kol_f'];

Example 1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
if ($i == 0) {
echo "I equals 0";
} elseif ($i == 1) {
echo "I equals 1";
} elseif ($i == 2) {
echo "I equals 2";
}

switch ($i) {
case 0:
echo "I equals 0";
break;
case 1:
echo "I equals 1";
break;
case 2:
echo "I equals 2";
break;
}
Example 2
1
2
3
4
5
6
7
8
9
10
11
switch ($i) {
case "Apple":
echo "I is apple";
break;
case "Bar":
echo "I is bar";
break;
case "Cake":
echo "I is cake";
break;
}

Cyclic operators

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
<HTML>
<BODY>
<H1>Debug Demo</H1>
<table border="1" width="700">
<tr bgcolor="red">
<th>Name</th>
<th>Address</th>
<th>Phone</th>
</tr>
<?php
$db = array(
array ("John", "E 10th St., NYC, NY 23742", "(212) 555-4456"),
array ("Francois", "12 Bd. de Grenelle, Paris, 74897","(33) 433-544"),
array ("Klaus", "312 Beethoven St., Frankfurt, Germany", "(44) 332-8065"),
array ("Shirly", "72 Independence St., Tel Aviv, Israel 67283", "(972) 156-7777"),
array ("Bill", "127 Maine St., San Francisco, CA 90298", "(415) 555-6565"),
array ("Bill", "127 Maine St., San Francisco, CA 90298", "(415) 555-6565")

);
function row_color($i){
$bgcolor1 = "white";
$bgcolor2 = "yellow";
if ( ($i % 2) == 0 ) {
return $bgcolor1;
} else {
return $bgcolor2;
}
}
function display_workers(){
global $db;
for ($i=0, $n=count($db); $i<$n; $i++) {
$worker_data = $db[$i];
$worker_name = $worker_data[0];
$worker_address = $worker_data[1];
$worker_phone = $worker_data[2];
print "<tr bgcolor=\"".row_color($i)."\">\n";
print "<td>$worker_name</td>\n";
print "<td>$worker_address</td>\n";
print "<td>$worker_phone</td>\n";
print "</tr>\n";
}
}
display_workers();
?>
</table>
</BODY>
</HTML>

1
2
3
4
$i = 1;
while ($i <= 10) {
echo $i++;
}

1
2
3
4
5
6
7
8
9
<? Php
$i = 1;
do {
echo $i++;
if($i==5) {
break;
}
} while ($i < 5);
?>

1
2
3
4
$a=array("Any", "jy", "Mitch");
while ( list ($f,$d) = each ($a)) {
echo $f . $d;
}

Example 1
1
2
3
4
$a=array("Any", "jy", "Mitch"); 
foreach ($a as $b=>$c){
echo "Key $b" ." ". "- $c ";
}

Example 2

1
2
3
4
5
6
foreach ($array as $key => $value) {
   // делаем что-либо с каждым элементом
   if (!next($array)) {
        // делаем что-либо с последним элементом...
    }
}

's Structures

Sontinue

Example 1
1
2
3
4
5
6
7
for ($i = 0; $i < 5; ++$i) {
if ($i == 2){
continue
; / / Print $ i;
}
echo "$i";
}
Example 2
1
2
3
4
5
6
7
8
$i = 0;
while ($i < 5) {
$i++;
while (1) {
echo "& & Inner <br>\n";
continue 2;
}
}
Example 3
1
2
3
4
5
6
7
8
9
10
11
12
13
$i = 0;
while ($i++ < 5) {
echo "Outer <br />\n";
while (1) {
echo \n";
while (1) {
echo \n";
continue 3;
}
echo "This never gets output. <br />\n";
}
echo "Neither does this. <br />\n";
}

Authorization

Nice Ajax Poll

Which one of my extensions is the best?

Statistics

Translate

русскийitalianoDeutschEnglishLATVIANукраїнськаfrançaispolski
1

Advertisement