SlideShare a Scribd company logo
1. ให้นักเรียนเขียนโปรแกรมประโยคเงื่อนไขโดยที่ค่าตัวแปรมีค่าเริ่มที่ 20120และน้อย
กว่า100000 ถ้าเงื่อนไขเป็นจริงให้แสดงคาว่า This website has low traffic
มิฉะนั้นให้พิมพ์ว่า This website has high traffic
คาตอบ This website has high traffic
2. ให้นักเรียนเขียนโปรแกรมประโยคเงื่อนไขโดยที่ค่าตัวแปรมีค่าเริ่มที่ 0 และเท่ากับ 5
ถ้าเงื่อนไขเป็นจริงให้แสดงคาว่า a equals 5 มิฉะนั้นให้พิมพ์ว่า a equals 6 หรือ a
is neither 5 nor 6
คาตอบ a is neither 5 nor 6
<?php
$traffic = 21020;
if ($traffic < 100000) :
echo "This website has low traffic.";
else :
echo "This website has high traffic.";
endif;
?>
<?
$a = 0;
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;
?>
3. ให้นักเรียนเขียนโปรแกรมประโยคเงื่อนไขโดยที่ค่าตัวแปรมีค่าเริ่มที่ 20120และน้อย
กว่า100000 ถ้าเงื่อนไขเป็นจริงให้แสดงคาว่า This website has low traffic
คาตอบ This website has more traffic
<?php
$traffic = 21020;
if ($traffic < 10000) {
echo "This website has lowest traffic.";
} elseif ($traffic < 20000) {
echo "This website has lower traffic.";
} elseif ($traffic < 100000) {
echo "This website has low traffic.";
} else {
echo "This website has more traffic.";
}
?>

More Related Content

PDF
Answer unit4.3.2
PDF
Answer unit4.2.3
PDF
Answer unit4.2.5
PDF
Answer unit4.1.1
PDF
Answer unit4.1.2
PDF
Answer unit4.2.4
PDF
Answer unit4.2.1
PDF
Introprogramphp
Answer unit4.3.2
Answer unit4.2.3
Answer unit4.2.5
Answer unit4.1.1
Answer unit4.1.2
Answer unit4.2.4
Answer unit4.2.1
Introprogramphp

More from KwanJai Cherubstar (19)

PDF
Programstructure
PDF
ความรู้เบื้องต้นเกี่ยวกับภาษาPhp
PDF
Unit3.1variables
PDF
Unit4maintain edit
PDF
Unit4maintain
PDF
Unit3coding
PDF
Unit2flowchart
PDF
Unit1 ph pprogram
DOCX
Answer unit4.4.1
PDF
Answer unit4.2.2
PDF
Answer unit3.2
PDF
Answer unit3.1
PDF
Answer unit2.3
PDF
Answer unit2.1
PDF
Answer unit1.3
PDF
Answer unit1.2
PDF
Answer unit1.1
PDF
Intro program php
PDF
Program structure
Programstructure
ความรู้เบื้องต้นเกี่ยวกับภาษาPhp
Unit3.1variables
Unit4maintain edit
Unit4maintain
Unit3coding
Unit2flowchart
Unit1 ph pprogram
Answer unit4.4.1
Answer unit4.2.2
Answer unit3.2
Answer unit3.1
Answer unit2.3
Answer unit2.1
Answer unit1.3
Answer unit1.2
Answer unit1.1
Intro program php
Program structure
Ad

Answer unit4.3.1