The Basic PHP Syntax

PHP was created to work with the HTML code so that it can be easily embedded in the HTML pages. When you create a PHP file without adding any HTML tags, then it is called a pure PHP file.

If you execute a PHP code on the server, then the plain HTML output is sent back to the web browser. There has been a unique enclosed tag used to identify the PHP code embedded in the HTML page.

Basic PHP Syntax

A basic PHP code starts with the < than followed by the question mark and then the words “PHP”. The PHP code can be easily placed anywhere in the HTML document.

A PHP script starts with :

The default file extension for PHP files is “.php”.

// PHP code goes here

A normal PHP file can contains some HTML tags, and some PHP code.

PHP File Extensions

Every file is firstly identified with the extension of that file. Servers also used extension and tags to identify file types and scripting language. Users must always save their PHP files with the “.php” extension. The older PHP file extensions also are shown below:-

  • phtml
  • php3
  • php4
  • php5
  • phps

Leave a Reply

Your email address will not be published. Required fields are marked *