How to Use PHP to Make a Switch for HTML5 and CSS3 Programming

By Andy Harris

Often, you run across a situation in HTML5 and CSS3 programming where you have one expression that can have many possible values. You can always use the structure to manage this situation, but PHP supplies another interesting option.


The code for this program uses the switch structure. Take a look at how it’s done:

<!doctype html>
<html lang="en">
<meta charset="UTF-8">
<p>Ask the magic 8 ball a yes or no question!</p>
$yourNumber = rand(1,8);
case 1:
print "<p><img src="images/8ball1.png" alt = "fat chance" /></p>";