Basic Syntax of PhP

2
207

In programming, syntax refers to the rules that specify the correct combined sequence of symbols that can be used to form a correctly structured program using a given programming language. Programmers communicate with computers through the correctly structured syntax, semantics, and grammar of a programming language.

The syntax is a way to a representation of PHP script. Basically, it gives the primary idea to specify the code format. It also specifies the area of a written code.

There are three ways to start PHP environment.

The most commonly and effective  PHP  syntax:

<?php
echo "Welcome to the world of PHP";
?>

In the given Example

It begin with (< ?php) and End with (? >).

echo statement is used to print the given string. Mandatory closing in (“ABCD”) double quotes. Terminate the script with the semicolon because the semicolon is known as the terminator.

Short or short open tags look like this:

<?    
    echo "welcome to the world of PHP";
?>

In the given above example.
We use Short tags. start and end with () respectively.
Declare the statement in between (), to display the output on browser
short open tags smoothly works on XAMPP server but Face problem on wamp server

if you are using  WAMP Server First you have to Set the short_open_tag setting in your php.ini file to on

HTML script tags:

<script language="PHP">
        echo "welcome to the world of PHP";
</script>

PHP is the server side Scripting language. So HTML script is also used to start PHP environment like another scripting language.

2 COMMENTS

LEAVE A REPLY

Please enter your comment!
Please enter your name here