PHP is forgiving
: Certain syntactical features like function prototypes and variable declarations are not needed in PHP. It stresses accommodation for the developer over accuracy.It has least set of syntactical principles that the code must take after.If any parse errors are found in the browser window, then it means PHP rules are not followed.HTML is not PHP
: HTML is a static library but PHP is a dynamic language.They can interact with each other but they are not the same.PHP syntax is relevant only with PHP since PHP is implanted in HTML components.All aspects of a report is interpreted as either PHP or HTML,depending on the labels.PHP syntax looks like C-language
: Loops,control structures also exist in PHP.PHP is case sensitive
: Once a variable declared in a case,it cannot be changed.Statements are terminated with semicolons.
Syntax
:
[php]
<?php write your php code here ?>
[/php]
Syntax
:
[php]
<?Write your code here?>[/php]
Syntax
:
[php]
<%Write your code here%>[/php]
Every PHP statement ends with a semicolon;.All these statements can be enclosed within block that start and end with curly braces.{}.
Types of comments:
Single Line comments
:Multiple lines comments
/* this is multi
Line comment */
[php]
<!DOCTYPE html>
<html>
<body>
<?
# This is a comment, and
# This is the second line of the comment
// This is a comment too. Each style comments only
print "An example with single line comments";
?>
<?
/* This is a comment with multiline
Author : John
Purpose: Multiline Comments Demo
Subject: PHP
*/
print "An example with multi line comments";
?>
</body>
</html>
[/php]
Output: