PHP Syntax

If you came from other programming languages like c/c++ and or Java, you will not have difficulty understanding PHP syntax as they have the same thing in common.

But unlike c/c++ or Java, PHP script is executed on the server and can be inserted within any HTML code and must start scripting block with <?php and end with ?>.

Below is an example of PHP file:

As you can see the “Hello World” is within the scripting block of <?php and ?>. If you sometimes see a block that starts with <? and end with ?>, this means that the shorthand support is enabled in the server.

But for compatibility, use the standard form (<?php).

At the end of the echo command there is a semicolon (;). This means that it is a separator used to separate its line of code from other line.

As of now this is the basic syntax of PHP. As we go on we will teach you on how to create PHP script one by one.

Comments

Add new comment

CAPTCHA
This question is for testing whether or not you are a human visitor and to prevent automated spam submissions.
12 + 3 =
Solve this simple math problem and enter the result. E.g. for 1+3, enter 4.