PHP Conditionals and Control Structures.

These are the typical conditional tests you want to have in a program like if. Control structures include elements like for and other loops. PHP has the following elements (see php.net for details on each). For the most part they are the same as other languages like C++ and Java. One new control element is "foreach".

Note: on foreach, it is a loop that lets you cyle through all the elements of of an array (like foreach in Perl). It can be used to cycle through both numerically indexed and associative arrays as follows:

foreach (array_expression as $value)      
    statement;
foreach (array_expression as $key => $value)      
    statement;

 

<html> 
 <title>Hello, PHP</title>  
<body bgcolor="#EFEFFF">  <p>

<?php  print "Hello, World!";  /* Notice the <?php ?> escape brackets. */  

?>  


</body>
</html>  


Try it out now
© Lynne Grewe