Standard PHP Syntax
One of the first scripts is run on the server, and the simple result results are sent back to the browser.
Basic PHP Syntax
one PHP script starts with the .
A print file always contains a html tag and some print script code
In the following example, instead of Simple Hatmall, only the first file has an example in which
The first is a script that shows the code “hello world” that uses the “echo” function code in the code.
On a web page.
Example
<!DOCTYPE HTML> | |
<html> | |
<head> | |
<title>PHP Syntax</title> | |
</head> | |
<body> | |
<?php | |
// Some code to be executed | |
echo "Hello, world!"; | |
?> | |
</body> | |
</html> |
Every PHP statement end with a semicolon (;) — this tells the PHP engine that the end of the current statement has been reached.
Embedding PHP within HTML
The first file is a simple file with the .oh extension. Inside a first file we can write html code Like we do in the html file, and also on the server side we can show the first code as we have given below.
Example
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="UTF-8"> | |
<title>A Simple PHP File</title> | |
</head> | |
<body> | |
<h1><?php echo "Hello, world!"; ?></h1> | |
</body> | |
</html> |
As in the example given above, we have told you to PHP the code inside the HTML
How to combine code to create a dynamic web page created in a simple way. If the results show the code on the path of the web page, then the difference that you will see is the first code <! First echo “Hello, World!” | The ” replaced with the output “Hello, world!”.
when you run this code the PHP engine executed the instructions between the tags and leave the rest of the thing as it is. At the end, the webserver send the final output back to your browser which is completely in HTML.
PHP Comments
A comment is a code in which PHP ignores files. The commenting command makes the code more attractive.Or it is easy to explain to the other developer what the code is coded
(Or when we look at the first code in the future, we can easily find out what has happened or not)
PHP support single-line as well as multi-line comments. To write a single-line comment either start the line with either two slashes (//) or a hash symbol (#). For example:
Example
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<title>PHP Comments</title> | |
</head> | |
<body> | |
<?php | |
// This is a single line comment | |
# This is also a single line comment | |
echo 'Hello World!'; | |
?> | |
</body> | |
</html> |
Currently slash followed bean asterisk (/ ) at the beginning of a comment to write with a multi-line comment. Asterisk followed by a slash ( /) at the end of the comment and comment. Are being given
Example
<!DOCTYPE HTML> | |
<html> | |
<head> | |
<title>PHP Comments</title> | |
</head> | |
<body> | |
<?php | |
/* | |
This is a multiple line comment block | |
that spans across more than | |
one line | |
*/ | |
echo "Hello, world!"; | |
?> | |
</body> | |
</html> |
Case Sensitivity in PHP
In PHP, keywords (e.g. if, else, while, echo, etc.), classes, functions, and user-defined functions are not case-sensitive.
In the example below, all three echo statements below are equal and legal:
Example
<!DOCTYPE html> | |
<html> | |
<body> | |
<?php | |
ECHO "Hello World!<br>"; | |
echo "Hello World!<br>"; | |
EcHo "Hello World!<br>"; | |
?> | |
</body> | |
</html> |
Variable names in PHP are case-sensitive. As a result the variables $color, $Color and $COLOR are treated as three different variables.
Example
<!DOCTYPE HTML> | |
<html> | |
<head> | |
<title>Case Sensitivity in PHP</title> | |
</head> | |
<body> | |
<?php | |
// Assign values to variables | |
$color = "blue"; | |
$Color = "red"; | |
$COLOR = "green"; | |
// Try to print variables values | |
echo "The color of the sky is " . $color . "<br>"; | |
echo "The color of the sun is " . $Color . "<br>"; | |
echo "The color of the tree is " . $COLOR . "<br>"; | |
?> | |
</body> | |
</html> |
If you try to run the above example code it will only display the value of the variable $color and produce the “Undefined variable” warning for the variable $Color and $COLOR.
However the keywords, function and classes names are case-insensitive. As a result calling the gettype() or GETTYPE() produce the same result.
Example
<!DOCTYPE HTML> | |
<html> | |
<head> | |
<title>Case Sensitivity in PHP</title> | |
</head> | |
<body> | |
<?php | |
// Assign value to variable | |
$color = "blue"; | |
// Get the type of a variable | |
echo gettype($color) . "<br>"; | |
echo GETTYPE($color) . "<br>"; | |
?> | |
</body> | |
</html> |
If you try to run the above example code both the functions gettype() and GETTYPE() gives the same output, which is: string.




I’m a DevOps/SRE/DevSecOps/Cloud Expert passionate about sharing knowledge and experiences. I am working at Cotocus. I blog tech insights at DevOps School, travel stories at Holiday Landmark, stock market tips at Stocks Mantra, health and fitness guidance at My Medic Plus, product reviews at I reviewed , and SEO strategies at Wizbrand.
Please find my social handles as below;
Rajesh Kumar Personal Website
Rajesh Kumar at YOUTUBE
Rajesh Kumar at INSTAGRAM
Rajesh Kumar at X
Rajesh Kumar at FACEBOOK
Rajesh Kumar at LINKEDIN
Rajesh Kumar at PINTEREST
Rajesh Kumar at QUORA
Rajesh Kumar at WIZBRAND