Let's Get Started with a PHP switch
Page!
- Open Notepad++
- Choose:
File -> New
- Copy the PHP
switch
Template (PHP) code (below)
- Paste that code into your new file
- Change the put-welcome-heading-here, and put-welcome-paragraph here
strings.
- Change the put-title-of-this-page-here to:
switch
- Click: File -> Save As
- Name your file: \www\switch.php
- Change the
Save as type:
to: PHP Hypertext Preprocessor (*.php)
- Click: Save
- Visit your page (http://buffalo.edu/switch.php) in your favorite web browser
- Make any changes
- Save your changes
PHP switch
Template (PHP)
<?php
$title = "put-title-of-this-page-here";
$h2 = "put-heading-of-this-page-here";
$par = "put-paragraph-of-this-page-here";
?>
<!doctype html>
<html>
<head>
<title><?php echo($title); ?></title>
<head>
<body>
<h2><?php echo($h2); ?></h2>
<p><?php echo($par); ?></p>
<?php
switch ($title) {
case "if/else":
echo("You are on the if/else
page.");
break;
case "switch":
echo("You are on the switch
page.");
break;
default:
echo("You are on the $title
page.");
}
?>
</body>
</html>
Output