Monday, July 20, 2009

PHP MYSQL TUTORIAL

PHP is a powerful tool for making dynamic and interactive Web pages.PHP is the widely-used, free, and efficient alternative to competitors such as Microsoft's ASP.In our PHP tutorial you will learn about PHP, and how to execute scripts on your server.
INTRODUCTION
What is PHP?

PHP stands for PHP: Hypertext Preprocessor
PHP is a server-side scripting language, like ASPPHP scripts are executed on the server
PHP supports many databases (MySQL, Informix, Oracle, Sybase, Solid, PostgreSQL, Generic ODBC, etc.)
PHP is an open source software
PHP is free to download and use
What is a PHP File?
PHP files can contain text, HTML tags and scripts
PHP files are returned to the browser as plain HTML
PHP files have a file extension of ".php", ".php3", or ".phtml"
What is MySQL?
MySQL is a database serverMySQL is ideal for both small and large applicationsMySQL supports standard SQLMySQL compiles on a number of platformsMySQL is free to download and use
more.............visit :: http://www.mahilalu.com/
Operators
Arithmetic
Relational
Logical
Concatenation
Assignment
Inc / Dec
Bitwise Operator
Ternary

Arithmetic
+ Addition
- Subtraction
* Product
/ Division
% Modules (5%2 = 1)

$a = $a + $b
$a + = $b
$a = $a - $b
$a - = $b
$a = $a * $b
$a * = $b
$a = $a / $b
$a / = $b
$a = $a % $b
$a % = $b

Relational
== Equals to
=== Identical ( It will check value and data type )
!= Not equals to
!== Not identical
> Greater then
<>= Greater then or Equals to
<= Less then or Equals to Logical
And &&
Or
Not !
Example
2 && $b>15) echo 'Pass'; else echo 'fail';?>
Concatenation
. or ,
Assignment
$a = 10 ;
$a = $b ;
Incrementation/ Decrementation
++ incrementation
-- Decrementation
Ex : $a = 10 ;
$a++; similar to ( $a + = 1) that is $a = $a + 1
$a-- ; similar to ( $a - = 1) that is $a = $a - 1
$a = 10 ;
Post increment
echo ($a++) ; - 10;
echo ($a) ; - 11;
Pre increment
echo (++$a) ; - 11;
echo ($a) ; - 11;
Note : Unari Operator takes one Value or variable . ( ! , ++ , -- )
Binary Operator takes two Values or variables .
Bitwise Operator
And &
Or
Xor ^
Example1

Output : 8
Note :
binary value - 1100
binary value - 1001
12 & 9 - 1000 -> decimal value 8 ( 1*23 + 0*22 + 0*21 + 0*20 )

Variable functions
Gettype()
Settype()
Isset()
Empty()
Unset()
Is_...()
Intval()
Example for gettype()
It is used to get the data type
Var_dump() is used to get datatype,length and value but it return only datatype

Example for settype()
1)It is used to set the data type to a variable
2) if it is set successful then it returns true (1) else it return false (null)

Example for isset()
If variable is existed it returns true(1) else it return false (null)

Example for empty()
If variable is empty the it will return true (1) else it return false (null)


Empty means :
False0Empty stringEmpty arrayEmpty objectNullNot existed
Non empty means :
True -infinity to + infinity ( Except 0 )Non empty stringNon empty arrayNon empty object
Example for unset()
It is not return any value.
It will remove allotted memory to the variable (it deletes the variable)

Example for is_..()
it will return true (1) else it return false (null)
is_integer(var)
ex 1:
-----------------------------------------------------------------------
ex 2:

-----------------------------------------------------------------------
is_bool(var)
is_string(var)
is_array(var)
is_object(var)
Example for intval()
when you performed arithmetic operation then “ string conversion method “ will work
But with out performed arithmetic operation , if you want to convert a value into int then intval() is useful

No comments:

Post a Comment