The PHP script or code is executed on the server and returned to the normal HTML format in the browser.
Basic Syntax of PHP
PHP scripts can be placed anywhere in a document.
PHP scripts start with <? php and end with ?>
PHP's default file extension is ".php".
HTML tags and some PHP scripting codes are commonly used in PHP files.
In the following example, we will look at an example of a simple PHP file, where a built-in function of PHP "echo" is used to take the output of "hello world" on a web page.
The PHP statement ends with a semicolon (;).
That is, in PHP, lowercase letters and uppercase letters are considered separately.
Although PHP is case-sensitive, not all types of keywords (such as if , else , for , echo , etc .), classes, functions, and user-defined functions are case-sensitive.
In the following example, all three echo statements are valid and equal
However, all variables are case sensitive.
The following example shows only the value of the $ name variable. Because $ name, $ NAME and Name are three different variables.
Since the $ NAME and $ Name variables are not defined, an error will appear when we try to output them.
Use of comments in PHP:
A comment is used to explain PHP code and make it more readable.
Comments are also used in PHP code to prevent the execution. Its use is especially noticeable when testing an alternative code.
Use of comments:
The purpose of writing your code is to make it easy for others to understand.
To write code documentation.
To recall what you wanted to do with the code. Because most programmers come back to their previous projects after a long time. Then the text of the comment reminds him of what he thought of those codes.
Supports several types of comments in PHP: