By | December 14, 2016

Embedding php is pretty easy.One basic advantage of PHP is the it can be embedded alongside HTML. For the code to do anything, you just need to pass it through a php engine for interpretation.

Default syntax

The default syntax contain php code starting from and ends with ?> . Every php statement ends with a delimiter ';'.

echo is similar to a print statement.

Short Tags
Though less motivated, a php code can be wriiten as

Caution: Short tags delimiters should not be used while making a php driven software intended to redistribution.


Another way for embedding php in your code is using srcipt

ASP style

Microsoft ASP provides a similar delimiting strategy as used by php. The delimiting strategy forms a specific pattern, starting the dynamic code using <% and closing the dynamic code using %>

Caution:This ASP style is no longer used form PHP 5.3.

Embedding multiple code blocks

You can use multiple php codes in a single page.For instance see this code:

Commenting on your code

Single line comment
Comment often do not require more than a single line.PHP supports C++ single line comment preface by a double slashed (//).

Shell syntax
PHP also supports C++ shell syntax in comments, using (#)

Multi line comments
PHP also supports multi line comments as same C++. The multi line comments begin with (/*) and end with (*/). This block can have many lines of comment.

Leave a Reply

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