PHP Tutorials From Beginners to Expert : Tutorial 1

What is PHP?

  • Php is server side scripting language.In other words php is a processing language.It process the scripts and returns the output in the form of HTML.
  • Php is not used for apperance but for processing.
  • Simple example of php is contact form.When we fill the inputs in contact form such as name,mail,message and subject and submit it the information is passed to the Blog/Website owner.
  • Php is responsible for passing this information.It takes the input from the form processes it and sends it to respective email.

PHP Tutorials:

php-historia2

Hot to give php tag :

Php tag is given by

<?php

//php code

?>

Printing a word in php :

  • Printing function in php is given by echo.
  • Below code prints “this is my first php code”
<?php

echo "this is my first php code";

?>

Variables in php :

  • žVariables in php are really simple.
  • žLets check the following example:
<?php
 $x=5;
 $y=6;
 $z=$x+$y;
 echo $z;
 ?>
  • žHere x and y are variables
  • žAs in Algebra ,variables can be used to hold values in php
  • žOn compiling this code we will get the answer 11.žAs simple as in algebra.

Rules for using variables in php :

  • žPhp statements and variables are case sensitive.
  • žVaribale must start with $.
  • Varibale name should start with a letter,underscore or character.
  • žVariable should be alpha numeric i.e it can start with a-z , 0-9, _
  • žVariable name should not contain spaces.
  • žIn php there is no need to define data type , php automatically identifies data type depending on its value.

Assigning variables to text value :

žWhen we assign variables to text value,put that value in double quotes.

  • žEg.
<?php

$x=“ajinkya”;

$y=5;

echo “$x $y”;

?>
  • žThe output will be ajinkya5
  • žIf we put $x=ajinkya instead of $x=“ajinkya” the code will not be executed.

Variables scope in php :

  • There are 4 type of variables in php.
  1. Local variables
  2. Global variables
  3. Static scope
  4. Parameter scope

We will study each one in detail in next tutorial variable scopes in php .If you have any question feel free to ask me.I will be glad to answer them.If you find this post useful share it with your friends.

In the following tutorials we have explained more ways to create a website, you will definitely like it.It’s simple and easy to understand  very valuable series of tutorials for beginners. Checkout the links.

HTML tutorials for absolute beginners : Understanding the basics

Dreamweaver CC Tutorials : Creating a fully functional Website

 

Leave a Reply