---
title: "Basic PHP Syntax"  
description: "PHP is a server side scripting language which is executed on server and result sent in plain html format to client browser.  A PHPscripting block al"  
author: "Anonymous User"  
published: 2011-09-02  
updated: 2020-03-04  
canonical: https://www.mindstick.com/articles/714/basic-php-syntax  
category: "php"  
tags: ["php"]  
reading_time: 2 minutes  

---

# Basic PHP Syntax

PHP is a [server side](https://www.mindstick.com/forum/143/close-popup-window-by-server-side-code) [scripting language](https://www.mindstick.com/blog/486/scripting-language) which is executed on server and result sent in plain html format to client browser.\

A [**PHP**](https://www.mindstick.com/articles/12165/registration-in-php) scripting block always starts with <?php and ends with ?>. A PHP scripting block can be placed anywhere in the html document. You can use shorthand tag <? (As [starting](https://www.mindstick.com/blog/12024/things-you-need-to-know-when-starting-your-own-business) tag) and ?> (as ending tag) rather than <?php (as starting tag) and ?> (as ending tag), but for more [compatibility](https://www.mindstick.com/blog/303291/best-practices-for-working-with-host-apis-security-compatibility-and-performance-considerations) you should have to use first one.

##### Syntax:

<? php ..... Scripting code to be executed.....?>

##### Example:

```
<html>   <head>         <title>First Php Script</title>   </head> <body>          <%-- Basic Php script syntax--%>         <?php                 <%--Some php scripting code here. --%>         ?> </body></html>
```

A PHP file contains [html tag](https://www.mindstick.com/forum/78/how-avoid-the-html-tag-and-remove-the-formating-of-copy-in-ajax-editor), just like html file, and contains some scripting code.

Here we have an example for displaying message with [**php**](https://www.mindstick.com/articles/12165/registration-in-php) script.

```
<html>   <head>         <title>First Php Script</title>   </head> <body>         <?php                 echo "Hello first PHP Script";         ?> </body></html>
```

Now type http://localhost:85/MySiteFile/ in URL web address of [web browser](https://answers.mindstick.com/qa/95505/what-are-the-pros-and-cons-of-using-safari-web-browser).

![Basic PHP Syntax](https://www.mindstick.com/mindstickarticle/b12ac7c2-4b9b-4104-bdb1-8fff45e2a10b/images/7af5bb86-3d57-4f6e-80c1-d74c5dbfa239.png)

##### Comments in PHP:

We use ‘//’ (double [forward slash](https://www.mindstick.com/forum/159257/backslash-vs-forward-slash-when-moving-files-in-python)) to make single-line comment and ‘/* */ ‘for multi-line comment.

```
<html>   <head>         <title>First Php Script</title>   </head> <body>         <?php                 // Starting PHP comment                 /* Multi line       Comment */                                          echo "Hello first PHP Script";         ?> </body></html>
```

\

---

Original Source: https://www.mindstick.com/articles/714/basic-php-syntax

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
