Laboratory work



Download 29,26 Kb.
Sana29.01.2022
Hajmi29,26 Kb.
#416921
Bog'liq
laboratory 22


Republic of Uzbekistan
Ministry of Higher and Secondary Special Education
Samarkand State University
Faculty of International Educational Programs
Department of Computer Science and
Programming Technologies
LABORATORY WORK
on the subject of Introduction to Computer Science.
Theme : PHP
Operators, If…Else…Elseif, Switch



Checked by: Eshtemirov Bunyod


Done by: Rustamov Ramziddin

Plan!




  1. Introducing PHP Operators ,

  2. PHP if …..else …Elseif,

  3. PHP switch! .

Introducing PHP Operators ,

Adding two numbers .!


$x = 10;
$y = 6;

echo $x + $y;


?>
Subtraction:
$x = 10;
$y = 6;
echo $x - $y; //
?>
Multiplication:
$x = 10;
$y = 6;

echo $x * $y;//result 60


?>


Division:
$x = 60;
$y = 6;

echo $x / $y; //result 10


?>


Modulus:


Remainder of $x divided by $y
$x = 10;
$y = 6;

echo $x % $y;//result 4


?>


Exponentiation:
Result of raising $x to the $y'th power!
$x = 10;
$y = 3;
echo $x ** $y;//relut 1000
?>
PHP if …..else …Elseif
$t = date("H");

if ($t < "20") {


echo "Have a good day!";
}
?>
Output "Have a good day!" if the current time is less than 20, and "Have a good night!" otherwise:
$t = date("H");
if ($t < "20") {
echo "Have a good day!";
} else {echo "Have a good night!";
}
?>
Output "Have a good morning!" if the current time is less than 10, and "Have a good day!" if the current time is less than 20. Otherwise it will output "Have a good night!":
Code:
$t = date("H");
if ($t < "10") {echo "Have a good morning!";
} elseif ($t < "20") {
echo "Have a good day!";
} else {
echo "Have a good night!";
}
?>
PHP switch
Use the switch statement to select one of many blocks of code to be executed.
$favcolor = "red";

switch ($favcolor) {


case "red":
echo "Your favorite color is red!";
break;
case "blue":
echo "Your favorite color is blue!";
break;
case "green":
echo "Your favorite color is green!";
break;
default:
echo "Your favorite color is neither red, blue, nor green!";//your favority color //is red
}
?>
Download 29,26 Kb.

Do'stlaringiz bilan baham:




Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©www.hozir.org 2024
ma'muriyatiga murojaat qiling

kiriting | ro'yxatdan o'tish
    Bosh sahifa
юртда тантана
Боғда битган
Бугун юртда
Эшитганлар жилманглар
Эшитмадим деманглар
битган бодомлар
Yangiariq tumani
qitish marakazi
Raqamli texnologiyalar
ilishida muhokamadan
tasdiqqa tavsiya
tavsiya etilgan
iqtisodiyot kafedrasi
steiermarkischen landesregierung
asarlaringizni yuboring
o'zingizning asarlaringizni
Iltimos faqat
faqat o'zingizning
steierm rkischen
landesregierung fachabteilung
rkischen landesregierung
hamshira loyihasi
loyihasi mavsum
faolyatining oqibatlari
asosiy adabiyotlar
fakulteti ahborot
ahborot havfsizligi
havfsizligi kafedrasi
fanidan bo’yicha
fakulteti iqtisodiyot
boshqaruv fakulteti
chiqarishda boshqaruv
ishlab chiqarishda
iqtisodiyot fakultet
multiservis tarmoqlari
fanidan asosiy
Uzbek fanidan
mavzulari potok
asosidagi multiservis
'aliyyil a'ziym
billahil 'aliyyil
illaa billahil
quvvata illaa
falah' deganida
Kompyuter savodxonligi
bo’yicha mustaqil
'alal falah'
Hayya 'alal
'alas soloh
Hayya 'alas
mavsum boyicha


yuklab olish