Practice Questions on PHP Basics
PHP Practice Questions
Topics: Variables, Conditional Statement, Switchcase, Looping Statements.
1) Write a program to print the given matrix. Use Nested for loop.
123
456
789
2) Write a program to calculate sum of the digits of above given matrix
3) Find given letter is consonant or vowel, you can use switch case or if-else
4) Compare password, conform password and print both are same or not
if same, print “successfully registered”
else print “passwords not matched”.
5) Based on the gender print profile image
6) Print in which subject student failed among in 6 subjects ($m1, $m2, $m3, $m4, $m5, $m6)
if marks > or equal to 40, print passed else failed
Hint - use if-else with or operator
7) First check username and password
next, check both system OTP and user OTP are same or
then print “login success”
else
print “login failed”
variables you need
$username, $password, $systemOTP, $userOTP
Hint -- use nested if
8) Check both systemcaptcha, and usercaptchas are same or not.
ex:
$systemCaptcha = "aCd9z";
$userCaptcha = "aCd9z";
9) find in which subject maximum marks obtrained
$m1 = 80;
$m2 = 60;
$m3 = 79;
10) $rating = 3; // allow max value <= 5
Print stars based on given rating
Ex: if rating =3 print 3 stars.
11) Based on the speed, show the text in different color
if speed is in between [60-100] print -- Fast in Red
if speed is in between [ 40-59] -- Average in Orange
if speed is in between [0-39] -- Slow in Green
$speed = 78;
12) Take 3 people's height and find who is taller
$person1 = 5.6;
$person2 = 5.4;
$person3 = 5.8;
13) Take the person weight and tell him Over weight, Underweight, Normal
14) Draw 10 Horizontal Lines using nested for loop with '-'.
👍Happy Coding..!!
Tags;
PHP Practice Questions | PHP Mock Test | PHP Mock Exam Questions |PHP Quiz Questions
Comments
Post a Comment