Latest web development tutorials

PHP syntax

PHP script is executed on the server, and then send the results back to the plain HTML browser.


The basic syntax of PHP

PHP scripts can be placed anywhere in the document.

PHP script<? Php start to?>End:

<? Php
// PHP Code
?>

PHP file the default file extension is ".php".

PHP file normally contains HTML tags, and some PHP scripting code.

Below, we provide a simple PHP file instances, it can be output to the browser text "Hello World!":

Examples

<! DOCTYPE html>
<html>
<body>

<h1> My first PHP page < / h1>

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

</ body>
</ html>

Running instance »

Each code line in PHP must end with a semicolon. Semicolon is a separator for the instruction set separate.

Through PHP, there are two on the basis of the instruction browser outputtext: echo and print.


Comments in PHP

Examples

<! DOCTYPE html>
<Html>
<Body>

<? php
// This is the PHP-line comment

/ *
this is
PHP multi-line comments
* /
?>

</ Body>
</ Html>

Running instance »