Resources | Scripts | Themes | Affiliate Programs | E-Commerce | Tutorials | Top Lists | Marketplaces
PHP Statements - Introduction and Examples
Category:
Tutorial Topic:
PHP statements are used to calculate and output data, which is then presented to the user by a web browser. All PHP statements end with:
;
Examples:
The following PHP statement saves the text Hello World to a PHP Variable $hi. Every piece of text in PHP statements need to be wrapped in ' ' or " ".
<?php
$hi = 'Hello World';
?>
The following php statement outputs the value of variable $hi. Variables should be used without ' ' or " " in PHP statements.
<?php
echo $hi;
?>
Text and variables can also be combined in a single PHP statement like
<?php
echo 'The value of variable is ' . $hi . '. I saved it for testing';
?>
In this example, variable and text statements are combined by the notation (.).
- Text: 'The value of variable is '
- Variable: $hi
- Text: '. I saved it for testing.'
The output of the above PHP statement will be:
The value of variable is Hello World. I saved it for testing.