3 PHP - PHP Fundamentals - PHP Tutorials

PHP Fundamentals

Basic Syntax

All PHP code must be enclosed inside <? and ?> closing tags
echo outputs text.

<? 
$a
=1;
echo 
$a;
 
?>

will display the value of $a which is 1

<? 
$a
=5;
echo 
"Display this text $a=$a";
 
?>

will display whatever is between the double quotes including the value of variables. Notice the \ used in the statement. The \ will escape the next character. Using a \ before special characters like " $ display the character. Using \

echo 'Displays this text $a'; Displays everything inside single quotes. Variables are not interpreted. The example above displays as Displays this text $a.

 1 2 3 4 5 6  >> Variables and Arrays
New Content