Sunday, June 2, 2013

Basic PHP Constructs


A construct is just short for control structure. Unlike an expression the construct creates a flow of control in the code. The construct controls how or when statements are executed, in order to create a structure of code that effectively tackles the task the programmer aims to achieve. Think of constructs like a place where code gets directed (or literally constructed) during execution. Imagine a busy intersection where lots of cars need to pass through. A construct is like a traffic light that directs how the traffic flows so that there isn’t an accident.


echo:
The most basic language construct you will run into in PHP is echo. It is used to send output to the standard output stream. The construct accepts any number of expressions each separated by an argument-separator (the comma).

Concatenation:
The concatenation operator(.) is used to put two string values together.

For example:
<?php
$txt1=”Hello World!”;
$txt2=”Have a nice day!”;
echo $txt1.” “.$txt2;
?>


No comments:

Post a Comment