because we are on the internet.

PHP Syntax

PHP is a server side language, PHP code is only executed on the server end, and return plain HTML result to the browser.

Basic PHP Syntax:

PHP scripting block starts with <?php and ends with ?>

<?php  ?>

A PHP scripting block is allowed to be placed anywhere in a PHP document.

You can start a PHP scripting block with <? and ends it with ?>, but these shorthand is not recommended.

<?php

?>

A PHP file is allowed to contains some HTML tags, simply like an HTML file, as well as some PHP scripting code.

What you see below is a very simple PHP script, which return to the browser a text “Hello World”:

<html>

<body>

<?php

echo “Hello World”;

?>

</body>

</html>

Each line of code in PHP requires ending with a semicolon.The semicolon is somehow like a separator, it tells the server to distinguish one line of PHP scripting from another.

There are two statements for outputing PHP text: echo and print, as what you read, we have used echo statement to output the “Hello World” text.

Note:Your PHP file must have a .php extension, otherwise, the PHP code can not be executed.

Comments in PHP:

In PHP, there are two types of comments:

// for making a single-line comment, while /* and */ for large comment block.

<html>

<body>

<?php

// This is a comment

/*This is

a comment block

*/

?>

</body>

</html>

Leave a comment

You must be logged in to post a comment.

 

About Author

Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Vestibulum at arcu. Integer et risus. Morbi id tellus. Integer felis. Mauris malesuada, turpis vitae facilisis euismod, dui arcu adipiscing sem, eu vulputate leo ante in lacus. Sed porta accumsan lectus. Aenean ac sem. In consequat tempus velit. Phasellus leo enim, adipiscing a, egestas nec, pretium ut, pede. Mauris sollicitudin diam et mauris. Sed quis enim vel augue egestas lobortis. Etiam tempus ipsum vel neque.