03- PHP Syntax

0
800

This tutorial is all about PHP Syntax.
Before we proceed to code our PHP script, we need to understand first what is the syntax of coding a PHP script. A syntax is a rule that should be followed in order to write a properly structured code.
If you have a background in programming other programming languages such as Java, C, and Perl, you don’t have to worry more about the syntax, because their syntax is almost similar to PHP and only the difference is that the PHP code contains a Tag like as the given syntax below.

PHP Code:

 

For shorthand:

 

In my experience, I strongly suggest that you must use a standard PHP syntax that includes <?php over shorthand code. This is to make sure that your scripts will run on other servers with different settings.

Here is the example PHP page with simple HTML

Before running this page in your browser, you need to save this file with .php extension(sample.php). As you observe in our code above, we included they’re a PHP command“echo” which we are going to discuss this in the later part of our tutorial. And just Java or C program, we need to add a semicolon at the end of our statement to signifies the end of the PHP statement.

Output:
PHP Programming is fun!

 

 

Readers might read also:

 

 

Facebook Comments

LEAVE A REPLY

Please enter your comment!
Please enter your name here

This site uses Akismet to reduce spam. Learn how your comment data is processed.