PHP if,else, elseif statementlar.
if statement- bitta shart to'g'ri bo'lsa, ba'zi amal bajaradi.
if....else statement- agar bitta shart togri, keyingisi xato bolsa amal bajariladi.
if...elseif....else- bunda ikki marta kop amallar bajariladi.
switch statement- bloklardan birini tanlash.
[color=red]
PHP If statement:
[/color]
Bunda bitta shart togri bolsa, amal bajariladi.
Sintaksis: if (condition) {
    code to be executed if condition is true;
}
[code=php]
<?php
$t = date("H");

if ($t < "20") {
    echo "Yaxshi kun!";
}
?>[/code]
*- nima bolganiga tushundingizmi? Bu yerda date("H"); orqali vaqtni aniqladik.
if ($t<"20"){
echo "Yaxshi kun!";
}
yani $t 20 madan kichik boldi, echo "Yaxshi kun!" ekranga chiqdi.
[color=red]
PHP If...else statement.
[/color]
Bunda avvalgi amal togri bolsa, keyingi amal xato bolishi korsatiladi.
Sibtaksis: if (condition) {
    code to be executed if condition is true;
} else {
    code to be executed if condition is false;
}
[code=php]
<?php
$t = date("H");

if ($t < "20") {
    echo "Yaxshi kun!";
} else {
    echo "Ajoyib tun!";
}
?>[/code]
*- nima boldi bu yerda? Qarang, bu yerda avvalgi date("H"); orqali vaqt aniqlandi.
if ($t<"20"){
echo "Yaxshi kun!";
}
// agar $t 20 dan kichik bolsa echo "Yaxshi kun!"
else (
echo "Ajoyib tun!";
}
// agar $t 20 dan katta bolsa echo "Ajoyib tun!" ekranga chiqadi.
[color=red]
PHP if...elseif....else statement.
[/color]
Sintaksis: if (condition) {
    code to be executed if this condition is true;
} elseif (condition) {
    code to be executed if this condition is true;
} else {
    code to be executed if all conditions are false;
}
[code=php]
<?php
$t = date("H");

if ($t < "10") {
    echo "Hayrli tong!";
} elseif ($t < "20") {
    echo "Yaxshi kun!";
} else {
    echo "Ajoyib tun!";
}
?>[/code]
*- yani bu yerda $t 10 dan kichik bolsa "Hayrli kun", $t 20 dan kichik bolsa "Yaxshi kun", $t 20 dan katta bolsa "Ajoyib tun" ekranga chiqadi.
[color=red]
PHP 5 switch Statement
[/color]
Sintaksis:
switch (n) {
    case label1:
        code to be executed if n=label1;
        break;
    case label2:
        code to be executed if n=label2;
        break;
    case label3:
        code to be executed if n=label3;
        break;
    ...
    default:
        code to be executed if n is different from all labels;
}
[code=php]
<?php
$favcolor = "qizil";

switch ($favcolor) {
    case "qizil":
        echo "Sening ranging qizil!";
        break;
    case "ko\'k":
        echo "Sening ranging ko\'k!";
        break;
    case "yashil":
        echo "Sening ranging yashil!";
        break;
    default:
        echo "Sening ranglaring qizil, ko\'k va yashil!";
}
?>[/code]
*- yani bu yerda bloklardan birini tanlasangiz, u amal bajaradi.
[color=red]Тупа адихаю и пью, до завтра :gg:[/color]