PHP
  Home arrow PHP arrow Page 6 - PHP 101 (Part 2) - Shakespeare's Rose
Dev Shed Forums 
Administration  
AJAX  
Apache  
BrainDump  
DHTML  
Flash  
Java  
JavaScript  
Multimedia  
MySQL  
Oracle  
Perl  
PHP  
Practices  
Python  
Reviews  
Security  
Style-Sheets  
Web Services  
XML  
Zend  
Zope  
Forums Sitemap 
IBM® developerWorks 
Sun Developer Network 
E-Commerce Hosting 
Linux Web Hosting 
Managed Hosting 
Small Business Hosting 
Moblin 
VPS Hosting 
Weekly Newsletter

 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
PHP

PHP 101 (Part 2) - Shakespeare's Rose
By: Vikram Vaswani and Harish Kamath, (c) Melonfire
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 4 stars4 stars4 stars4 stars4 stars / 10
    2000-08-08

    Table of Contents:
  • PHP 101 (Part 2) - Shakespeare's Rose
  • Form...
  • ...And Function
  • Operating With Extreme Caution
  • Shakespeare In The Matrix
  • If Not This, Then What?
  • Fortune Smiles
  • Submitting To The King
  • Miscellaneous Notes

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    ADVERTISEMENT


    PHP 101 (Part 2) - Shakespeare's Rose - If Not This, Then What?


    (Page 6 of 9 )

    In addition to the "if" statement, PHP also offers the "if-else" construct, used to define a block of code that gets executed when the conditional expression in the "if" statement evaluates as false.

    The "if-else" construct looks like this:

    if (condition) { do this! } else { do this! }
    As you can see, this construct can be used to great effect in the last example - instead of two separate "if" statements, we can combine them into a single "if-else" statement.


    <html> <head> <basefont face="Arial"> </head> <body> <center> <? // check name and print appropriate message if ($name == "neo") { ?> <font face="Arial" size="-1"> Welcome to the Matrix, Neo. <p> May The Force be with you...oops, wrong movie! </font> <? } else { ?> <font face="Arial" size="-1"> I wonder if you've heard of Shakespeare, <? echo $name; ?>. <p> He postulated that a rose by any other name would smell just as sweet. <p> Unfortunately for you, I disagree. Access denied. </font> <? } ?> </center> </body> </html>

    More PHP Articles
    More By Vikram Vaswani and Harish Kamath, (c) Melonfire


     

       

    PHP ARTICLES

    - Sub Classing Exceptions in PHP 5
    - Authentication for Web Application Security
    - Building a Content Management System with Co...
    - Filters and Login Systems for Web Applicatio...
    - Working with the Email Class in Code Igniter
    - Building Your Own System Tray Application Us...
    - Structuring Your Projects for Web Applicatio...
    - Inserting, Updating and Deleting Database Ro...
    - Building Your Own Desktop Notepad Applicatio...
    - Web Application Security Overview
    - Working with the Active Record Class in Code...
    - Generate PDF Documents with PHP on the Windo...
    - Sending Email with PHP Networking
    - Performing Strict Validation with the Code I...
    - The preg_replace_callback() function in PHP





    © 2003-2008 by Developer Shed. All rights reserved. DS Cluster 3 hosted by Hostway
    Stay green...Green IT