PHP Syntax

create a php file and type the following code:

echo "Hello!"

Name the file as test.php and store it in the /html directory.

In the browser address bar to access the php file:, the output is as follows:


If view the source code of the page through the browser :


In this example, we output a string "Hello!" With the echo command.

From this example can be seen:

  • The PHP file or PHP code segment begins with "<?php" and ends with "?>", php code in the middle.
  • Each statement ends with a ; sign

Complete example with html code :

  <title>PHP test</title>
      echo "Hello!"

PHP code and HTML code can be mixed.

echo is a PHP built-in instructions for the output of one or more strings, and echo similar print.

Copyright 2014-2017 by All Rights Reserved.