3.5.10

Write your first PHP Program

For writing php programs
install notepad++ Editor

1. Write php program with in "<?php" and "?>" tags.

2. You can also write php program with in "<?" and "?>" tags. these tags are called 'short open tags'. You need to modify configuration in "php.ini" file.


Write your first Program :

<?php
echo "my first program";
echo "<br/>";

echo "php - hypertext preprocessor";
?>


  • Save the file "firstprogram.php" in root folder "Apache\htdocs\" (with extension ".php" )
  • run the file in browser (IE or FF) type "http://localhost/firstprogram.php"  and press Enter.
Explanation:
line no.1 : <?php 
  • php starting tag
line no.2 : echo "my first program"; 
  • echo - command to display data on browser windows", type date between double or single quotes ("example" || 'example')
  • ";" - termination operator for a statement.
  • it displays ::  my first program
line no.3 : echo "<br/>"; 
  • <br/> - HTML tag for line break, you can add html tags in double quotes to run in php language.

line no.4 : echo "php - hypertext preprocessor";
  • echo - display data on browser windows".
  • ";" - termination operator.
  • it displays ::  php - hypertext preprocessor

 line no.5 : ?>
  • php closing tag.

No comments:

Post a Comment