+ 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
4 Respuestas
+ 5
read this
http://stackoverflow.com/questions/4098104/odd-behaviour-in-a-switch-statement
try this
switch (strval($day)) {.....}
+ 2
thanks @Burey..
+ 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??
0
if $day is storing numbers, how it is possible to compare it with string cases. is It working?