PHP Tutorial Tutorials - PHP Syntax

PHP Syntax

Canonical PHP Syntax

<?php
...
?>
They tell the PHP parsing engine to treat the enclosed code block as PHP code,differentiate PHP code from other elements in the page.

Short-open (SGML-style) tags

Short or short-open tags look like this:
<?
...
?>
You should set short_open_tag in the configuration file php.ini

we suggest that you use the canonical form (<?php) rather than the shortopen form.

Statement

Every PHP statement end with a semicolon (;) , it should never be forgotten.

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

if the semicolon is missing:
Parse error: syntax error, unexpected 'echo' (T_ECHO), expecting ',' or ';' in D:\Apache24\htdocs\index.php on line 3

Date:2019-09-30 17:26:16 From:www.Lautturi.com author:Lautturi