A code block is a list of statements grouped as one unit.
In PHP we use {} to wrap code blocks and notify the compiler by saying, "hey this is a group of statements."
The following code group two print statements together and outputs A and B if the sky color is blue.
<?PHP $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.
The following code shows how to create three Simple statements.
<?php //an expression statement 2 + 3; //another expression statement print("PHP!"); //a control statement if(3 > 2) { //an assignment statement $a = 3; } ?>
The code above generates the following result.
In programming a comment is the description for our code.
There are three ways to create comments in PHP:
//
and #
mean "Ignore the rest of this line,"
<?php print "This is printed\n"; // print "This is not printed\n"; # print "This is not printed\n"; print "This is printed\n"; ?>
The code above generates the following result.
/*
means "Ignore everything until you see */
."
<?php print "This is printed\n"; /* print "This is not printed\n"; print "This is not printed\n"; */ ?>
The code above generates the following result.