Basic Syntax of PHP
The set of rules, principles and processes that define the structure of statements in a computer language is called Syntax.
The set of rules or principles that define how a PHP program can be written called PHP Syntax.PHP (Hypertext Preprocessor) is a widely used open-
Each PHP command is ended with a semicolon, like this:
$x += 10;
2).The $ symbol
In PHP, you must place a $ in front of all variables. This is need to make
the PHP parser faster.
$Number = 1;
$string = “Hello”;
$array = array(“One”, “Two”, “Three”);
Variables are the names you give to computer memory locations that which are used to store values in a computer program.
In PHP all variables start with a $ sign.
$username = “Fred Smith”;
$count = 17;
for storing the floating numbers, the syntax is same
$count = 17.5;
$Students = array(‘Arian’, ‘Theon’, ‘Grego’, ‘Chris’, ‘Anne’);
The main syntax of PHP code:
// PHP code
“echo” is a built-in PHP function that is used to display the output text on a web page.
The scripts of php is begin with <?php and ends with ?>.
The syntax of a simple PHP file:
<h1> Heading </h1>
echo “PHP CODE”;
A small PHP “HELLO WORD” example
<h1> My First PHP Example </h1>
echo “HELLO WORLD :)”;
To learn more about PHP and PHP Comments Click Here.