44 lines
1002 B
Markdown
44 lines
1002 B
Markdown
|
---
|
||
|
title: PHP Syntax and Comments
|
||
|
---
|
||
|
|
||
|
### PHP Syntax
|
||
|
|
||
|
The structure of a PHP syntax somewhat looks like:
|
||
|
|
||
|
```shell
|
||
|
<?php
|
||
|
|
||
|
// Your PHP code goes here.
|
||
|
|
||
|
?>
|
||
|
```
|
||
|
This PHP script can be placed anywhere in the document.
|
||
|
A PHP file generally have HTML tags, and some scripting code .
|
||
|
The default file extension for PHP files is `.php`.
|
||
|
|
||
|
### How to make comments in PHP?
|
||
|
|
||
|
A comment in PHP code is a line that is not read/executed as part of the program. Its only purpose is to be read by someone who is looking at the code.
|
||
|
|
||
|
In PHP, comments can be make by two ways either single lined or multi-lined.
|
||
|
The code snippet given below explains it:
|
||
|
|
||
|
```shell
|
||
|
<?
|
||
|
// This is a single-line comment
|
||
|
|
||
|
# This is also a single-line comment
|
||
|
|
||
|
/*
|
||
|
This is a multiple-lines comment block
|
||
|
that spans over multiple
|
||
|
lines
|
||
|
*/
|
||
|
?>
|
||
|
```
|
||
|
|
||
|
### More information
|
||
|
|
||
|
For more resources you can visit: https://www.w3schools.com/php/php_syntax.asp
|