Jump to content

w3schools tutorials help


aszxcv

Recommended Posts

The Switch Statement i am having difficulty understanding this concept when i practice i like to change examples so i can learn by messing with codebut i am keep error with my modificationso can someone modified the example below so i can see java script:bbc_pop()

<html><body><?phpswitch ($x){case 1:  echo "Number 1";  break;case 2:  echo "Number 2";  break;case 3:  echo "Number 3";  break;default:  echo "No number between 1 and 3";}?></body></html>

Link to comment
Share on other sites

Just assign 1 to $x:

<?php$x = 1;switch ($x){case 1:  echo "Number 1";  break;case 2:  echo "Number 2";  break;case 3:  echo "Number 3";  break;default:  echo "No number between 1 and 3";}?>

the switch() statement is like a series of ifs. Here's an equivalent to your switch statement:

if ($x == 1) {  echo "Number 1";} else if($x == 2) {  echo "Number 2";} else if($x == 3) {  echo "Number 3";} else {  echo "No number between 1 and 3";}

Link to comment
Share on other sites

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"	"http://www.w3.org/TR/html4/loose.dtd"><?php$date1 = date(d);switch ($date1){	case 10:	echo "today tenth";	break;	case 14:	echo "not";	break;	case 7:	echo "today 17";	break;	default:	echo:"not 10";}	?>

i have this code but i am getting error

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...