PHP
  Home arrow PHP arrow Page 3 - PHP Statements and Beginning Loops
Dev Shed Forums 
Administration  
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 
Dedicated Servers 
E-Commerce Hosting 
Linux Web Hosting 
Managed Hosting 
Small Business Hosting 
Download TestComplete 
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 Statements and Beginning Loops
By: James Payne
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 3 stars3 stars3 stars3 stars3 stars / 5
    2007-11-05

    Table of Contents:
  • PHP Statements and Beginning Loops
  • If
  • Else
  • Elseif
  • Here We Go Loop de Loop
  • For Loop

  • 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

    Dell PowerEdge Servers

    PHP Statements and Beginning Loops - Else
    (Page 3 of 6 )


    <html>

    <body>


    <?php


    $your_answer = "Yes";


    if ( $your_name == "Yes")

    {

    echo Now I am the both the Happiest and Fattest man alive!';

    }

    else

    {

    echo 'Jennifer Aniston is prettier than you!';

    }

    echo 'I'm Brad Pitt's cousin, Fat Pitt.';

    ?>


    </body>

    </html>

    Several things to note about the above code: 1) Jennifer Aniston is not hotter than Angelina Jolie, unless Jennifer Aniston or her lawyer are reading this, in which case she is very hot and a great actress to boot 2) If the value in $your_answer is equal to Yes, then the following will print:

      Now I am both the Happiest and Fattest man alive!

      I'm Brad Pitt's cousin, Fat Pitt.

    If the value in $your_answer had not been Yes, this would have printed:

      Jennifer Aniston is prettier than you!

      I'm Brad Pitt's cousin, Fat Pitt.

    Note that either way the line: I'm Brad Pitt's cousin, Fat Pitt prints out. This is because that echo is placed outside of the IF...Else statement and prints regardless of whether the criteria is met.

    More PHP Articles
    More By James Payne


       · Hey thanks for stopping by. In this article I discuss conditional statements like...
       · On page 3:There's the following...
       · I enjoy your writing style and the subject matter but there are a few...
     

       

    PHP ARTICLES

    - Setting Up a Web-based Image Hosting Service
    - Comparing Files and Databases with PHP Bench...
    - Setting Up a Web-Based Image Gallery
    - Using Timers to Benchmark PHP Applications
    - Benchmarking Applications with PHP
    - Setting Up a Web-Based File Manager: PHPfile...
    - Developing a Modular Class For a PHP File Up...
    - Setting Up a Web-Based File Manager: bfExplo...
    - Defining a Custom Function for File Uploader...
    - Parsing Child Nodes with the DOM XML extensi...
    - Creating an Error Handling Module for a PHP ...
    - Accessing Attributes and Cloning Nodes with ...
    - Retrieving Information on Selected Files wit...
    - Handling HTML Strings and Files with the DOM...
    - Building File Uploaders with PHP 5

     
    Accelerating Trading Partner Performance
     
    Competing on Analytics
     
    Cost Effective Scaling with Virtualization and Coyote Point Systems
     
    Five Checkpoints to Implementing IP Telephony
     
    Hosted Email Security: Staying Ahead of New Threats
     




    © 2003-2008 by Developer Shed. All rights reserved. DS Cluster 1 hosted by Hostway