http://phpmyanmar.com

Your First Php Program
Posted By - Ko Ko - May 19, 2006

Summary :
Here I will tell you how to write your very first PHP program

Show Myanmar Version show-myanmar-font

Your First Php Program

Before writing our very first Php program a short explanation about Php tags will be needed.

Php code can be freely mixed with html codes.

When html code ends and php code started you have to type in the "php start tag".

Also when the php code ends and html code started again, the "php end tag" have to be type in again.

Various pairs of "php start tag" and "php end tag" are shown below:-

PHP Start and End Tags

Tag Style

Start Tag

End Tag
Standard tags <?php ?>
Short tags <? ?>
ASP tags <% %>
Script tags <script language="php"> </script>

See below how these 4 pairs of Php Tag are used:-

<?php
put your php code here;
?>
<?
put your php code here;
?>
<%
put your php code here;
%>
<script language="php">
put your php code here;
</script>


Now lets write our first php program.

Open MS Notepad and type the code shown below. Observe carefully how the start and end tags were used.

<html>
<head>
<title>hello</title>
</head>
<body>
<?php
echo "Hello World!";
?>

</body>
</html>


Save as "hello.php" in folder "www" shown below.



Now close the notepad and open the browser.

In the address box type in http://localhost/hello.php and click enter.

If you have done everything properly, you will see "Hello World!" as shown below.

Congratulation, you have written your first php program successfully.


Posted as - [programming] [php]
0 comment            submit comments