Friday, November 14, 2008

Basic syntax for php

The most basic syntax for php scripting block starts with:

<?php and ends with ?>


It is embedded inside html and need to be save as .php extension in order for it to be executed.

In html, the sign below was used for inserting comments between the codes without being executed.

<!-- -->

However, it is different for php:

// your comment


for short comments



/* your long
comment */


for long comments



echo is use for displaying the text to the browser output window



Below is the example code:


< html>
< body>
<?php
echo "I love the World";
?>
</body>
</html>



After saving it as .php, browser will read it as:

I love the World

No comments: