PHP Syntax

PHP Syntax

PHP Syntax


PHP is a procedural and object-oriented language for coding webpage markup text to be transformed into HTML format.

PHP is embedded in the HTML page and the code must contain the following tags:

<?php

// php code

?>

or

//This is shortened form of an operator "<?php", Not all interpreters, it is processed,

//so recommend using the full form.

<?


//php code

?>

If you have PHP code which is included in the HTML and you want the browser to interpret all correctly, then you should save the file with the extension .php, instead of the standard .html.

Example index.php

<!DOCTYPE html>
<html>
   <head>
       <title>My First PHP Page</title>
   </head>
   <body>
      <?php

         echo ("Hello web !") ;

	  //Outputs a string  Hello W3docs !

       ?>
   </body>
</html>

With command 'echo', we display the text (We will return to this command in the next lessons.

As you can see in the example there was a semicolon after the line of code PHP.

The semicolon indicates the end of the operation in PHP, and you should never forget about it otherwise you got a fatal error.

For example, if we repeated our command output inscriptions, «Hello W3docs!» A few times, we have to put a semicolon at the end of each line.

Spaces between PHP expressions are ignored. If the code ten blank lines, for example, to format, then do not worry, they will not be visible in the result. As well as tabs (Tab).

<!DOCTYPE html>
<html>
   <head>
     <title>My First PHP Page</title>
   </head>
   <body>
      <?php

           echo  ("Hello Web !") ;

                                     echo  ("Hello Web !") ;echo  ("Hello Web !") ;

           		echo  ("Hello Web !") ;

	//Outputs a string  Hello W3docs !Hello W3docs !Hello W3docs !Hello W3docs !


       ?>
   </body>
</html>
Reactions

Post a Comment

0 Comments

close