PHP syntax is easy to learn. The code always starts with <?php and ends with ?>. Those delimiters tell a server that the code wrapped inside is a PHP code.

Here are the bullet points explaining the PHP code syntax:

  • PHP script starts with “<?php”, it can be started anywhere in the document.
  • PHP script stops with “?>”, this syntax will terminate the PP script.
  • Each command inside the PHP script has a terminator which is “;”, which is similar to C language, and it terminates the current command.
  • PHP is not case sensitive for all the functions, conditions and command statements.
  • There are three ways to comment a line or paragraph in PHP:
    • //”, this will comment out everything in front of it in this line.
    • #”, this is also single line comment.
    • /*”, this will start commenting everything comes after until a terminator “*/” is used.
  • The above mentioned syntax explained in the figure below:

PHP basic syntax

Figure: Example of the syntax used

 

›› go to examples ››