6.5.10

PHP - Tutorial II

Variable declarations:

Declare variables using '$' symbol, starting with alphabet characters and "_" allowed.

Ex: $id, $student_name, $count, $var1  etc.,

Assigning values to varibles, are describes the datatype of variable.

Declare string varibales with in double quotes.

Ex:  $id = 1;   //integer
      $studnent_name = "phppandits" // Strings
      $ave_marks = "98.88";
     

5.5.10

Interview Questions - PHP

1. What is PHP, Explain?

  • PHP is web development server side scripting language. 
  • Hypertext Preprocessor - PHP.
  • It is a Open source technology.
2. Latest versions of PHP?
  • Latest versions are 5.2.14 (stable) and  5.3.2 
 
3. "echo " is a functional or statement?
  • "echo"  is a function.  

4. Explain short open tags?
  • short open tags are "<?" and "?>".
  • for short open tags, we need to modify php configuration file i.e., php.ini
  • short_open_tags = Off (default), Change On.

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.