Saturday, 11 January 2014

PHP crash course -1

                 PHP stands for HYPERTEXT PREPROCESSOR  

Short Introduction to PHP

  • php IS A SERVER scripting language like ASP
  • php script are executed on server
  • It support many databases like MYSQL, Informix, Oracle, Sybase, Solid, ODBC etc..
  • php is an open source software  

Related post : Basic funda of Internet Surfing for Person wan't to be hacker


  • PHP runs on different platform (windows,Linux,UNIX,etc)
  • compatible with almost all servers used in Nowdays
  • FREE available
  • easy to learn 
Before we start I wan't to clarify that we assume you are familiar with at least one any other language . Best for those who are familiar with C programming as PHP is very similar to C . only few differences are there like PHP did't require pre declaration of variable .

Preparing Environment to Run PHP program in your PC.
for Windows user Download XAMPP
& follow this Video for setup : Watch this video In HD

Start with Very First PRogram "HELLO WORLD"
A variable in PHP starts with a $ sign  
echo is funtion to print just like printf in C

 //simple question  
 $text="Hello World";  // test is a variable
 echo " ".$text;  

Related Post Easiest Way to Create Ad hoc Network (without any Software)

I suggest you to type it in your notepad save & Run for better perception .

How to find length of string similar to C . PHP also have a function name strlen() .
Now See this example program .

 // length of string  
 $text="hello World";  
 echo "length of string is ".strlen($text)." & string is ".$text;  

Here $text is a variable assign to string "hello World" . then we pass this variable to function strlen() which return length of string.

Now strpos() : fun used to search for character or world  within a string it takes two arguments first is string in which search has to perform And second is what we have to search.

 // strpos() : fun used to search for character or world within a string  
 $text = "welcome to World of PHP";  
 echo " String is : ".$text."\n Search position of {\"of \"}is =".strpos($text,$find);  

output returns the position of first occurrence of  searched element . If not found then return FALSE


It is same as C programming or any other programming language .

  • +   
  • -
  • *
  • /
  • %
  • ++
  • --
  • Basic Example of using Operator

 // Operators in PHP +,-,*,/,%,++,--  
 echo "x=$x & y=$y ";  
 echo "z=x+y : z=$z : addition";  
 //similarly try other operator  

similarly try other operator

Assignment Operator

It is also same as Used in C programming Language Or any other language

           Is THE same As

  //Assignment Operator
 $x=1; //equality operator 
 $x+=$y;  // x=x+y
 echo "x = $x";
 // <br /> for  line break
 echo "<br /> You can similarly tast other Operators ";

Comparison Operators :

Also similar to other language like C

Is equal  to
5==8  return false
Is Not Equal to
5!=8  return True
Is Not Equal to
5<>8  returns false
Is greater than
5>8 returns FALSE
Is less than
5<8 returns TRUE
Is greater than or equal to
5>=8 return false
Is less than or equal to
5<=8 returns false

Related Post : How to host your website for FREE (google drive )


X=6,    y=3
(x<10 && y>1) return True
X=6 , y=3
(x==5||y==5) return True
X=6, y=3
!(x==y) return True

we will show you example of this in next section .....
In next section we will talk about logic in php & looping in php

PHP crash course -2 
PHP crash course -3 

PHP crash course -4 ( GET POST & REQUEST function )

Related Post : How to free your Browser from unwanted search extensions

1 comment:

  1. Hey Nice Blog!! Thanks For Sharing!!!Wonderful blog & good post.Its really helpful for me, waiting for a more new post. Keep Blogging!
    best java training in coimbatore
    php training in coimbatore
    best php training institutes in coimbatore



Blogger Widgets