php Basic Syntax

In the given tutorial we will study how to write the basic syntax of php:

php Basic Syntax

php Basic Syntax

     

In the given tutorial we will study how to write the basic syntax of php:

<?php

?>

The above mentioned tag will be included in each php file and each php coding has to be written within this tag.

<?php

echo "Hello World";

?>

The above coding will print Hello World in the output screen or web page.

We can combine both php and html file in a single file, following example illustrates that:

Code: 

<html>

<body>This is html portion<br/></body>

</html>

<?php

echo"This is in php portion";

?>

Output:

This is html portion
This is in php portion

php syntax is more or less similar to any other popular language like: C, ASP, Java etc. In this language semicolon is as important as other language. There are many more similarities are also present like in php white spaces don't make any special difference.

Example:

<?php

echo"

This

is

in

php

portion";

?> 0

Output:

This is in php portion