Can anyone please explain about this code's output i didn't understand how it comes.. | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 2

Can anyone please explain about this code's output i didn't understand how it comes..

<?php $day = 0; switch ($day) { case 'Mon': echo 'First day of the week'; break; case 'Tue': echo 'Second day of the week'; break; case 'Wed': echo 'Third day of the week'; break; case 'Thu': echo 'Working day'; break; case 'Fri': echo 'Friday!'; break; default: echo 'Weekend!'; break; } ?> here is the code

9th May 2017, 6:19 PM
Lalit Nebhani
Lalit Nebhani - avatar
4 Answers
+ 5
9th May 2017, 6:47 PM
Burey
Burey - avatar
+ 2
thanks @Burey..
9th May 2017, 7:15 PM
Lalit Nebhani
Lalit Nebhani - avatar
+ 1
yes it is working but the problem is when i write 0 it goes to 1st case but if I write any other number it goes to default... y this so??
9th May 2017, 6:37 PM
Lalit Nebhani
Lalit Nebhani - avatar
0
if $day is storing numbers, how it is possible to compare it with string cases. is It working?
9th May 2017, 6:35 PM
Ganesh Prasad
Ganesh Prasad - avatar