create a php file and type the following code:
<?php 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: http://127.0.0.1/test.php, 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 :
<html> <head> <title>PHP test</title> </head> <body> <p> <?php echo "Hello!" ?> </p> </body> </html>
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.