PHP Code Blocks

Description

A code block is a list of statements grouped as one unit.

Syntax

In PHP we use {} to wrap code blocks and notify the compiler by saying, "hey this is a group of statements."

Example

The following code group two print statements together and outputs A and B if the sky color is blue.


<?PHP/*from w w w.  j av a2s  .  c om*/

$sky_color = "blue";

if($sky_color == "blue") {
     print("A \n");
     print("B \n");
}

print("Here I am from java2s.com.");

?>

The code above generates the following result.





















Home »
  PHP Tutorial »
    Language Basic »




PHP Introduction
PHP Operators
PHP Statements
Variable
PHP Function Create
Exception
PHP Class Definition