PHP Syntax

PHP syntax Tutorial will explain you What is PHP syntax? with examples.

<?php ?>

Within  these two tags a PHP scripting block is composed, it might be set at whatever place in a PHP file.

On servers with shorthand back prepared you can begin a code block with <? and close with ?>.

Standard PHP syntax i.e. ( <?php ?> ) guarantee that your scripts will work, indeed while running on different servers with diverse settings, so we dependably suggest that you utilize the standard form(<?php ?>) instead of the shorthand form.

Example of a simple PHP script :

Its necessary to place a semicolon at the closure of every statement. Semicolon demonstrates the close of line and disconnects a line from an another.

Echo and print are utilized to yield text in php. In above sample we have utilized “echo” to yield message “A simple PHP Example.”
Note: The file must have a .php extension. If file has a .html extension, the PHP code won’t be executed.

Comments in PHP

In PHP,

  • // is used for a single-line comment and
  • /* */ this for commenting a large block of code.

Example on Comments in PHP:

SHARE
Previous articlePHP Installation
Next articlePHP Variables
I am a young Information Systems Security Engineer(CEH). I had started with penetration testing when i am 17 years old. It all started with Kali linux and Metasploit.In free time i will play with Security holes/Bug bounty/Pentesting and Hacking !!!