• Home
  • PHP
  • PHP Introduction and Variables, Operators in PHP

PHP Introduction and Variables, Operators in PHP

  • (4.0)
  • | 1628 Ratings

PHP Introduction:

  • Rasmus Lerdorf is the founder of the PHP in 1995.
  • PHP is the server side scripting language.
  • Php needs a server to excute the file.
  • Php files should be saved with .php as its extension “.php3”, or “.phtml”
  • Or else our server will not excute unknown extension apart from .html, .cpi, .cgs,
  • Php support all the data base . that present in the market


  • Php can be worked on all the operating systems that is windows,linux,max,solaries…etc
  • Php can communicate with different servers

Ex:-SMTP(Simple mail transfer protocal),imap (internet max access protocal), LDAP, Informix, Oracle, Sybase, Solid, PostgreSQL

  • PHP  can be install as a software tags we get many of the server files

Ex: -Xampp, Wamp, easy php, mamp

  • PHP stands for PHP: Hypertext Preprocessor
  • PHP is an open source software
  • PHP is free to download and use
  • PHP is easy to learn and runs efficiently on the server side

Checkout PHP Interview Questions

Xampp: – xampp stands for

a—————————–>apache(web server)
m—————————->mysql(database file)
p—————————->perl(perl scripting in php)
p—————————->php/my admin (web database tool)

php current version is 5.3.8

wamp: – wamp stands for

w—————————->window exv
a—————————–>apache(web server)
m—————————->mysql(database file)
p—————————->php/my admin (web database tool)

Mamp: – mamp stands for

m—————————–>mac ‘os’
a—————————–>apache(web server)
m—————————->mysql(database file)
p—————————->php/my admin (web database tool)

Apache contain the  1-65535 ports                                1-1024 pre-reserved ports
Tem: – temp holds session details & temp upload files
Htdocs: – after installing xampp we have to store our files into the folder called htdocs. Once files are saved in htdocs we can open with the location path as
 echo:-echo is the output method in php



In PHP, we use // to make a one-line comment or /* and */ to make a comment block:


Echo:-echo as the arguments can print multiple arguments. Echo as a function can print only one argument
Print: -print as an argument can print only one argument.print also a function
Ex: – print”arg
Printf: – printf will take formatting string with respected values as print
Ex: –printf(“(int%d) (float%f) (string %s) (asci%c)”);
Print-r: – print-r will print array of string
Ex: – $g = array (10,20,30,true,’kalam’);
Var-dump: –it is also printing method which is used debugging the errors very easily. This not used in production level (live environmental)

Related Page: Headers, Downloading And File Uploading In PHP



  • Variables are “containers” for storing information.
  • Variables in PHP starts with a $ sign, followed by the name of the variable
  • The variable name must begin with a letter or the underscore character
  • A variable name can only contain alpha-numeric characters and underscores (A-z, 0-9, and _)
  • A variable name should not contain spaces
  • Variable names are case sensitive (y and Y are two different variables)

  • In PHP, a variable does not need to be declared before adding a value to it.
  • In the example above, notice that we did not have to tell PHP which data type the variable is.
  • PHP automatically converts the variable to the correct data type, depending on its value.
  • In a strongly typed programming language, you have to declare (define) the type and name of the variable before using it.

Related Page: Data Types In PHP

PHP has four different variable

  • local
  • global
  • static
  • Super global array of variable


A variable declared within a PHP function is local and can only be accessed within that function.


When a function is completed, all of its variables are normally deleted. However, sometimes you want a local variable to not be deleted.
To do this, use the static keyword when you first declare the variable.


Global scope refers to any variable that is defined outside of any function.
Global variables can be accessed from any part of the script that is not inside a function.
To access a global variable from within a function, use the global keyword:


$global is the super global array variable. This is the pre-defined keyword. In php we have mainly some of the super global variables. This can be used with their keywords.

i) $_EVN: – this is used for getting the information of your operating system ($_ENV (PATH))
ii) $_SERVER: – will give you the information about your server(apache information)
iii) $_GET: – it is used for form processing through get method (or) query string
iv) $_POST: –this is used for form processing through post method in secure manner
v) $_REQUEST: –will send the form through both get and post and cookie
vi)$_COOKIE: – this is used to get the information about the browser who is using the web(computer)
vii)$_SESSION: –it is used to get the information of the user in between login and logout details are store at server machine

Related Page: Cookies, Sessions And Buffer In PHP


1. Assignment operator:    = is used to assign values to variables in PHP
2. Arithmetic operator:         +,-,/,*,%
3. Increment & decrement operator:     i++,++I  & i–, –i
4. Comparison operator:      ==,!= ,===
5. Relational operator: <=, >=, <>
6. Logical operator: &&, ||, and, or
7. Error handling operator:  –
8. scope resolution & this operator:    ::—–>scope,   &——->this

Ex: -operator.php



Conversion of the one data type into another data type is known as type casting. in php we have mainly two types of casting

1. Temporary type casting
2. Permanent type casting

Related Page: Conditions And Loops In PHP

1. Temporary type casting: – casting which can be done for single step by pre-defined the data type keyword. That particular variable will hold Temporary type casting

2. Permanent type casting: – this can be done by using pre-defined key-word set type.which hold two arguments

Syntax: – set type (var name,’int’);


conversion of data types by using expression to another data types are  known as type juggling


i) Isset: –Isset of variables will check with the variable initialize are not and return Boolean
ii) empty(var name): – empty function will check the variable are not and return Boolean
iii) Unset (var name): –this function will remove the variable (or) delete the variable (or) initialize variable
iv) get type(var name): – this function will let us known the argument the data type in the form of string .this should be used because the coming variable this would be depreciated

Subscribe For Free Demo

Free Demo for Corporate & Online Trainings. Protection Status