Code Newbie
News     Forums     Search     Members     Sign Up    

My Code Newbie
Username

Password

Articles/Snippets
ASP Classic
ASP.NET
C
C#
C++
HTML / CSS
Java
Javascript
Linux / BSD
Perl
PHP
Python
Ruby
SQL
VB 6
VB.NET

C.N. Friends
  Planet Rome

Link to Us!
Code Newbie
  Code Newbie
    php
  » Alternate Syntaxes
      by falsepride
 Page 1 of 1 
   

(Login to remove green text ads)
PHP has an alternative syntax for some of its control structures(if, while, for, foreach, and switch). The basic form of the alternate syntax is to change the opening brace({) to a colon (:) and the closing brace(}) to endif;, endwhile;, endfor;, endforeach;, or endswitch.

Example:
PHP Code:
<?php
if ($number == 1):
    echo 
"number equals 1";
    echo 
"...";
elseif (
$number == 2):
    echo 
"number equals 2";
    echo 
"!!!";
else:
    echo 
"number is neither 1 nor 2";
endif;
?>





 
 Page 1 of 1 
   

Rate This Article
1 2 3 4 5 6 7 8 9 10





Copyright © 2000-2006, Milano Interactive
Web Hosting provided by Portal 360 Web Hosting
Open Circle