You are here:

PHP Tutorial 2: PHP Script Syntax and HTML File Compatibility

This tutorial will guide you the basic syntax PHP supports. This is in fact the basic and important criteria for any programming language.

PHP code is executed at the server and a plain text result is sent to your browser. To execute this script effectively there has been a PHP script block. The complete PHP code has to be written inside this block.

<?Php
//Code or PHP script?>

Servers that support shorthand support enables you to write the script in <? ?> tags. For maximum compatibility, it is always recommended to keep your script between<?php ?> tag.

The important thing to be remembered as far PHP is considered is, The PHP script is executed by the server. You don’t need to put efforts to execute the script.

PHP within HTML page

Another feature that makes PHP more interesting is its easy compatibility with HTML file. You don’t need to work hard to make PHP script execute in HTML file. Just place the PHP script between the <body> tag to execute the script. Important point to be remembered is when you have PHP script in HTML file save the code with .php extension and not with .html.