in ,

PHP Syntax

PHP Syntax
PHP Syntax

In this tutorial, you will learn about PHP Syntax step by step. So without much to do, let’s get started.


In this tutorial, you will learn-

In this article, you will learn-

What is PHP?

• PHP is an acronym for “PHP: Hypertext Preprocessor”
• PHP is a widely-used, open source scripting language
• PHP scripts are executed on the server
• PHP is free to download and use

PHP is an amazing and popular language!
It is strong enough to be on the center of the biggest blogging system on the web (WordPress)!
It is deep enough to run large social networks!
It is also easy enough to be a beginner's first server side language!

PHP Syntax

A PHP script is executed the server, and the plain HTML end result is sent again to the browser.


Basic PHP Syntax

A PHP script may be placed everywhere within the document.

A PHP script begins with <?php and ends with ?> :

<?php
// PHP code goes here
?>

The default file extension for PHP files is “.php“.

A PHP file typically consists of HTML tags, and some PHP scripting code.

Below, we have an example of a simple PHP file, with a PHP script that uses a built-in PHP characteristic “echo” to output the text “Hello World!” on a web page:

Example

<!DOCTYPE html>
<html>
<body>

<h1>My first PHP page</h1>

<?php
echo "Hello World!";
?> 

</body>
</html>

Note: PHP statements end with a semicolon (;).


PHP Case Sensitivity

In PHP, keywords (e.G. If, else, while, echo, and many others.), classes, functions, and user-defined functions are not case-sensitive.

In the example below, all three echo statements below are identical and legal:

Example

<!DOCTYPE html>
<html>
<body>

<?php
ECHO "Hello World!<br>";
echo "Hello World!<br>";
EcHo "Hello World!<br>";
?> 

</body>
</html>

Note: However; all variable names are case-sensitive!

Look at the example beneath; most effective the primary statement will show the value of the $color variable! This is because $colour, $COLOR, and $coLOR are treated as three distinct variables:

Example

<!DOCTYPE html>
<html>
<body>

<?php
$color = "red";
echo "My car is " . $color . "<br>";
echo "My house is " . $COLOR . "<br>";
echo "My boat is " . $coLOR . "<br>";
?> 

</body>
</html>

READ NEXT

PHP Introduction

PHP Installation


This is about PHP Syntax, and we hope you have learned something from this tutorial and share your opinion about this tutorial. What do you think about it, and if you think this tutorial will help some of your friends, do share it with them.



salman khan

Written by worldofitech

Leave a Reply

PHP Installation

PHP Installation

PHP Comments

PHP Comments