All about PHP

Introduction of PHP

  • Rasmus Lerdorf unleashed the first version of PHP way back in 1994.
  • PHP is a recursive acronym for “PHP: Hypertext Preprocessor”.
  • PHP is a server side scripting language that is embedded in HTML.
  • It is used to manage dynamic content, databases, session tracking, even build entire e-commerce sites.
  • Which means that Client user make request using browser and then Server compile and execute the PHP file and return the result in plain html file to the user.
  • The extension of PHP file is .php (e.g: myfile.php)
  • The code of php written inside the <?php    php code should be written here  ?>

PHP Variable :

  • Variable is a name given to memory locations where different constants are stored.
  • Variable may vary during the execution of the program.
  • Example: Z=2.2*X+6-Y+32; here Z ,  X and Y are variables Which may vary during execution.
  • php variable followed by the $ dollar sign (e.g: $variable_name;  $name;)

Display output :

echo keyword is used to show the output . there is another function exist to display output such as printf(); etc..

PHP simple program :

<?php 
$name=”devilx”;
echo “The name is “.$name;
?>

Output:
The name is devilx

If you write code inside quote php compiled it as a string.

 

How to compile php code:

To compile php code there is two method.

  1. online
  2. offline.
  • In online we need a website and  website hosting server from where we can compile php code.
  • But in offline , we need to install xampp or wamp software on the computer
  • search google for xampp software then install it on your computer.  Find xampp folder in your c: drive or where you install xampp , inside the xampp folder locate htdocs folder, all files that you want to compile should be reside here.
  • Open notepad the write the about code in it , save the file with named test.php in the htdocs folder.
  • now open xampp control panel and the start the services apache and mysql.
  • Open Browser the enter address localhost/test.php
  • that’s all you are in your local server and the result will be displayed on your browser.

learn c language that is base language and all language follow the same features of this language such as variable , constant, loops, array,  .. etc..

now we will cover next part of php such as how to create webpage using php ..

for database tutorial follow this link  DATABASE PHP