Let's Get Started with a PHP if/else Page!

  1. Open Notepad++
  2. Choose: File -> New
  3. Copy the PHP if/else Template (PHP) code (below)
  4. Paste that code into your new file
  5. Change the put-welcome-heading-here, and put-welcome-paragraph here strings.
  6. Change the put-title-of-this-page-here to:
  7. Click: File -> Save As
  8. Name your file: \www\ifelse.php
  9. Change the Save as type: to: PHP Hypertext Preprocessor (*.php)
  10. Click: Save
  11. Visit your page (http://buffalo.edu/ifelse.php) in your favorite web browser
  12. Make any changes
  13. Save your changes

PHP if/else Template (PHP)

$title = "put-title-of-this-page-here"; 
$h2    = "put-heading-of-this-page-here"; 
$par   = "put-paragraph-of-this-page-here"; 
<!doctype html>
    <title><?php echo($title); ?></title>
    <h2><?php echo($h2); ?></h2>
    <p><?php echo($par); ?></p>
    if ($title == "if/else") {
      print("You are on the if/else page.");
    } else {
      print("You are not on the if/else page. :-(");