PhpMyanmar.com logo Php Tutorial
Home
Php Tutorial
 Echo
 If

Php Tag
Show Myanmar Version
 show-myanmar-font
Printer Friendly Page

As Php codes can freely mix with Html codes, special tags are needed to seperate them.

All PHP code must be written between a pair of special start tag and end tag

PHP Start and End Tags

Tag Style

Start Tag

End Tag

Standard tags

<?php

?>

Short tags

<?

?>

ASP tags

<%

%>

Script tags

<script language="php">

</script>

Examples of php tag usage are shown below:-

PHP Code:
<?php
      phpinfo ();
?>




<?
      phpinfo ();
?>




<script language="php">
       phpinfo ();
</script

We like to suggest to use the standard form (which includes the <?php  ?>). This will ensure that your scripts will work on all different servers.

How to Save Your PHP Pages

Web pages that contain Php codes must be saved with .php extension.Then only the server will parse the Php codes.

Example:- A simple HTML & PHP page

Below is an example of a .php file where PHP and HTML codes were written together.

PHP and HTML Code:
<html>
    <head>
        <title>PHP Page</title>
    </head>
    <body>
        <?php
            echo "Hello World!";
        ?>

    </body>
</html>

After saving the above codes as a "helloworld.php" file, place it on a PHP enabled server and view it with your web browser.

You should see "Hello World!" displayed.

Display:
Hello World!

PHP function echo was used to to write "Hello World!" to the browser.

More about this PHP function and many others will be explained later.

The Semicolon!

Every line of Php code must end with a semicolon. It signifies the end of a PHP statement and should never be forgotten.

For example, if we repeated our "Hello World!" code several times, then a semicolon is needed at the end of each statement.

PHP and HTML Code:
<html>
    <head>
        <title>My First PHP Page</title>
    </head>
    <body>
        <?php
            echo "Hello World! ";
            echo "Hello World! ";
            echo "Hello World! ";
            echo "Hello World! ";
            echo "Hello World! ";
        ?>
    </body>
</html>
Display:
Hello World! Hello World! Hello World! Hello World! Hello World!

White Space

Whitespace is ignored between PHP statements.This means it is OK to have one line of PHP code, then 20 lines of blank space before the next line of PHP code. You can also press tab to indent your code and the PHP interpreter will ignore those spaces as well.

PHP and HTML Code:
<html>
    <head>
        <title>My First PHP Page</title>
    </head>
    <body>
            <?php
                echo "Hello World!";








                echo "Hello World!";
            ?>
    </body>
</html>
Display:
Hello World!Hello World!

Note
For more detail please see Php Manual at http://www.php.net

Processing time -- 0.0195 seconds.

b64bc07917e22a8d12faf5e69f4a1f2c