Php is a open source plat form, This blog will help you to learn php concepts by experts.
To install PHP we have some third party tools
EX :
XAMPP
WAMP
Easy PHP
Note :
Our s/w is XAMPP , it includes Apache , My SQL , PHP , Perl for XP
Every server has some root Directory ( where we have to save the programs )
XAMPP - htdocs
WAMP - www
Easy PHP - www
-------------------------------------------------------------
All web servers are deped on Port 80
We can change the port no in :
XAMPP\apache\conf\httpd.conf
-------------------------------------------------------------
Create your folder in
C:\xampp\htdocs to save your programs ( ex : satish)
-------------------------------------------------------------
Ex 1 :
echo 'Welcome';
?>
Save the file in your folder satish ( a.php )
Run the program :
Go to browser
http://localhost/satish
select your program from the list to run it
Note :
1) if you save your PHP program with the name index.php in your folder satish
the the program will automatically run when you are enter http://localhost/satish in the browser
2) instead of giving localhost we can give like this also http://127.0.0.1/satish
-------------------------------------------------------------
Variable
Variable is a memory location where we can store the values.
Ex 1 :
Var $a;
$a = ‘srihitha’; - Wrong
Ex 2 :
Var $a = ‘srihitha’; - Wrong
Ex 3 :
$a = ‘srihitha’; - correct
Conditions for variable names :
First char of var name must be in A-Z (or) a-z (or) _ (underscore) .
Spaces are not allowed.
Avoid built in functions and reserve words as variable names.
Data Types :
Numaric ( int – 4 bytes , float – 8 bytes )
String ‘abc’ or “abc”
Boolean True or False
Note :
If any char create problem in a string then use \
Ex :
“Hai \” I am satish “
\ indicates to browser that coming char is not a special char.
Ex 1 :
echo "Hai \" I am satish "
?>
Ex 2 :
$a = '10';
$b = 20;
$c = $a + $b;
echo $c;
?>
Note : with using string conversion method it will convert string into integer when u Preformed arithmetic operation
Ex 3 :
$a = '10abc4';
$b = 40;
$c = $a + $b;
echo $c;
?>
Ex 4:
$a = 'abc5';
$b = 10;
$c = $a + $b;
echo $c;
?>
Boolean
Boolean a = true;
Boolean a = false;
Note : don’t put any quotations ( Ex : ‘treue’ )
Ex :
$a = true;
echo $a;
?>
----------------------------------------------------------------
To get the data type of var
Ex 1 :
$a = true;
var_dump($a);
?>
It will display data type and value.
Ex 2 :
$a = 'abc';
var_dump($a);
?>
It will display data type,length and value.
Ex 3 :
$a = 10;
var_dump($a);
?>
It will display data type and value.
Note :
“ “ are used for variable expansion
Ex :
$a = 10;
echo $a;
echo '$a';
echo "$a";
?>
-------------------------------------------------------------
Concatenation symbol is . or ,
For next line we can use ‘
’
-------------------------------------------------------------
Ex :
$a = 'abc';
$b = 'xyz';
echo $a.'
';
echo $b;
?>
Thursday, July 16, 2009
Subscribe to:
Posts (Atom)