Easy Tutorial
❮ Func Filesystem File Exists Func String Get Html Translation Table ❯

PHP Syntax


PHP scripts are executed on the server, and then the pure HTML results are sent back to the browser.


Basic PHP Syntax

A PHP script can be placed anywhere in the document.

A PHP script starts with <?php** and ends with **?>:

The default file extension for PHP files is ".php".

PHP files usually contain HTML tags and some PHP scripting code.

Below, we provide a simple example of a PHP file that outputs the text "Hello World!" to the browser:

Example

<!DOCTYPE html>
<html>
<body>

<h1>My first PHP page</h1>

<?php
echo "Hello World!";
?>

</body>
</html>

Each line of code in PHP must end with a semicolon. The semicolon is a delimiter that separates sets of instructions.

With PHP, there are two basic commands for outputting text to the browser: echo and print.


Comments in PHP

Example

<!DOCTYPE html>
<html>
<body>
<?php
// This is a single-line PHP comment
/*
This is a 
multi-line
PHP comment
*/
?>
</body>
</html>
❮ Func Filesystem File Exists Func String Get Html Translation Table ❯