PHP is a server-side scripting language, which means that PHP scripts are executed on the server and the result is sent to the client as plain HTML.

PHP Tags

PHP scripts are always enclosed within the PHP opening and closing tags. The default syntax for these tags is as follows:

// Your PHP code goes here

Everything outside these tags is considered plain HTML (or other types of code, like JavaScript or CSS), and everything inside these tags is treated as PHP code.


Comments are a useful way to leave notes for yourself and others in the code. PHP supports single-line and multi-line comments:

// This is a single-line comment

This is a multi-line comment
It spans multiple lines

Echo and Print Statements

The echo and print statements are used in PHP to output data to the screen. Both can be used interchangeably in most cases, but echo is slightly faster:

echo "Hello, Humans!";
print "Hello, Humans!";


In PHP, semicolons (;) are used to denote the end of a statement, similar to languages like C, Java, and JavaScript:

echo "Hello, Humans!"; // Note the semicolon at the end


Variables in PHP start with a $ sign, followed by the name of the variable:

$name = "JMartian";
echo $name; // Outputs: Martian

Case Sensitivity

In PHP, all keywords (like if, else, while, echo, etc.), classes, functions, and user-defined functions are NOT case-sensitive. However, all variable names are case-sensitive.

Last updated