PHP Syntax
PHP Tutorial » PHP Syntax
A PHP script can be placed anywhere in HTML code and starts with: <?php cod php ?> :
Syntax of PHP:
<?php
// PHP code is placed here
?>
// PHP code is placed here
?>
my_file.php - The default file extension for PHP files is ".php".
Below, we make an example of a simple PHP file, with a PHP code that uses a function "echo" to output the text "Hello, how are you doing?" on a web page:
Example: a simple PHP file inside HTML code
<!DOCTYPE html>
<html>
<body>
<h1>My first PHP page</h1>
<?php
echo "Hello, how are you doing?";
?>
</body>
</html>
Note: PHP statements end with ";" (semicolon without qutes).
PHP Case-Sensitivity, example
In PHP, keywords as: echo, if, else, while, etc. classes, functions, and user-defined functions are not case-sensitive..
Example: not case-sensitive.
<!DOCTYPE html>
<html>
<body>
<?php
ECHO "Hello, how are you doing?<br />";
echo "Hello, how are you doing?<br />";
EcHo "Hello, how are you doing?<br />";
?>
</body>
</html>
PHP variable names are case-sensitive
All variable names are case-sensitive.
Example: case-sensitive.
<!DOCTYPE html>
<html>
<body>
<?php
$color = "white";
echo "My big boat is ". $color ."<br />";
echo "My little house ". $COLOR ."<br />";
echo "My little house is ". $coLOR ."<br />";
?>
</body>
</html>
Variable name rules:
In PHP, variables start with the $ sign followed by the variable name;
The name must begin with the "_" character or a letter;
The name CANNOT start with a digit;
The name can contain alphanumeric characters and underscores;
Variable names are case-sensitive ($age is not the same as $AGE, but they are different variables)
php syntax checker, php syntax tree, error unexpected '' expecting '' end of file, if, checker online, best practices
PHP Syntax - php tutorial
Online Editor
This tool makes it easy to create, adjust, and experiment with custom colors for the web.
HTML Templates

Magnews2 is a modern and creative free magazine and news website template that will help you kick off your online project in style.
CSS HTML Layout

Find here examples of creative and unique website layouts.
Free CSS HTML Menu

Find here examples of creative and unique website CSS HTML menu.