 PHP stands for Hypertext PreProcessor.
 PHP is a server side scripting language that is
embedded in HTML.
 PHP allows web developers to create dynamic
web pages.
 It is integrated with a number of popular
databases, including MySQL, PostgreSQL,
Oracle, Sybase, Informix and SQL Server.
 PHP was written in the C programming language
by Rasmus Lerdorf in 1994.
 PHP originally stood for “Personal Home Page”.
 Simplicity
 Efficiency
 Security
 Flexibility
 PHP code must be included inside one of the 3
special markup tags:
<?php PHP CODE HERE ?>
<? PHP CODE HERE ?>
<script language=“php”>
PHP CODE HERE
</script>
<html>
<head>
<title>Sample PHP</title>
</head>
<body>
<h1>
<?php echo "Hello PHP Developers"; ?>
</h1>
</body>
</html>
 Variables are used to store the data.
 Here are the most important things about
variables in PHP:
i. All variables are denoted with a leading dollar
sign($).
ii. Variables do not have intrinsic types.
iii. PHP does a good job of automatically converting
types from one to another when necessary.
 PHP variables can be one of four scope types:
i. Local variables
ii. Function parameters
iii. Global variables
iv. Static variables
 A constant is a name or an identifier for a simple
value.
 A constant value cannot change during the execution
of the script.
 To define a constant you have to use define()
function and to retrieve the value of a constant.
 You can also use the function constant() to read a
constant’s value.
 PHP has 8 datatypes:
i. Integers
ii. Doubles
iii. Booleans
iv. NULL
v. Strings
vi. Arrays
vii. Objects
viii. Resources
 n is replaced by the newline character
 r is replaced by the carriage-return character
 t is replaced by the tab character
 $ is replaced by the dollar sign itself ($)
 " is replaced by a single double-quote (")
  is replaced by a single backslash ()
 Arithmetic Operators(+,-,*,/,%,++,--)
 Comparison Operators(==,!=,>,<,>=,<=)
 Logical or Relational Operators(and,or,&&,||,!)
 Assignment Operators(=,+=,-=,*=,/=,%=)
 Conditional or Ternary Operators( ?: )
 if-else Statement
if (condition)
code to be executed if condition is true;
else
code to be executed if condition is false;
 elseif Statement
if (condition)
code to be executed if condition is true;
elseif (condition)
code to be executed if condition is true;
else
code to be executed if condition is false;
 Switch Statement
switch (expression)
{
case label1:
code to be executed if expression = label1;
break;
case label2:
code to be executed if expression = label2;
break;
default:
code to be executed if expression is different from
above labels;
}
 for Statement
for (initialization; condition; updation)
{
code to be executed;
}
 while Statement
while (condition)
{
code to be executed;
}
 do-while Statement
do
{
code to be executed;
}
while (condition);
 foreach Statement
foreach (array as value)
{
code to be executed;
}
 An array is a data structure that stores one or
more type of values in a single variable.
 Types of Arrays:
i. Numeric Array
ii. Associative Array
iii. Multidimensional Array
 These arrays can store numbers, strings and any
object.
 Here we have used array() function to create
array.
 Associative array will have their index as string
so that you can establish a strong association
between key and values.
Creating Array:
$array_name=array(“str1”=>value1,
“str2”=>value2, ……
“strn”=>valuen);
Accessing Array Elements:
$array_name[‘str1’];
 A multi-dimensional array each element in the
main array can also be an array and each element
in the sub-array can be an array and so on.
 A function is a piece of code which takes one or
more input in the form of parameter and does
some processing and returns a value.
 Creating Function
function function_name(parameters list)
{
/* Code Here */
}
 Calling Function
function_name(parameters list);
 Cookies are text files stored on the client computer
and they are kept of use tracking purpose.
 There are 3 steps involved in identifying returning
users:
i. Server script sends a set of cookies to the browser.
ii. Browser stores this information on local machine for
future use.
iii. Next time, when the browser sends any request to the
web server, it sends those cookies information to the
server and server uses that information to identify the
user.
 PHP provided setcookie() function to set a cookie.
setcookie(name,value,expire,path,domain,security);
 To access cookies, use either $_COOKIE[name] or
$HTTP_COOKIE_VARS[name] variables.
 You can use isset() function to check if a cookie is set or
not.
CONNECTING TO MYSQL DATABASE
Opening a Database Connection
connection mysql_connect(dbserver, user, password,
new_link, client_flag);
Closing Database Connection
bool mysql_close(resource $link_identifier);
Selecting a Database
$retval=bool mysql_select_db(dn_name,connection);
Creating a Database/Executing Query
bool mysql_query(sql,connection);
Retrieving Data from Database
mysql_fetch_array($retval, type_array);
mysql_fetch_assoc($retval);

PHP

  • 2.
     PHP standsfor Hypertext PreProcessor.  PHP is a server side scripting language that is embedded in HTML.  PHP allows web developers to create dynamic web pages.  It is integrated with a number of popular databases, including MySQL, PostgreSQL, Oracle, Sybase, Informix and SQL Server.
  • 3.
     PHP waswritten in the C programming language by Rasmus Lerdorf in 1994.  PHP originally stood for “Personal Home Page”.
  • 4.
     Simplicity  Efficiency Security  Flexibility
  • 5.
     PHP codemust be included inside one of the 3 special markup tags: <?php PHP CODE HERE ?> <? PHP CODE HERE ?> <script language=“php”> PHP CODE HERE </script>
  • 6.
    <html> <head> <title>Sample PHP</title> </head> <body> <h1> <?php echo"Hello PHP Developers"; ?> </h1> </body> </html>
  • 7.
     Variables areused to store the data.  Here are the most important things about variables in PHP: i. All variables are denoted with a leading dollar sign($). ii. Variables do not have intrinsic types. iii. PHP does a good job of automatically converting types from one to another when necessary.
  • 8.
     PHP variablescan be one of four scope types: i. Local variables ii. Function parameters iii. Global variables iv. Static variables
  • 9.
     A constantis a name or an identifier for a simple value.  A constant value cannot change during the execution of the script.  To define a constant you have to use define() function and to retrieve the value of a constant.  You can also use the function constant() to read a constant’s value.
  • 10.
     PHP has8 datatypes: i. Integers ii. Doubles iii. Booleans iv. NULL v. Strings vi. Arrays vii. Objects viii. Resources
  • 11.
     n isreplaced by the newline character  r is replaced by the carriage-return character  t is replaced by the tab character  $ is replaced by the dollar sign itself ($)  " is replaced by a single double-quote (")  is replaced by a single backslash ()
  • 12.
     Arithmetic Operators(+,-,*,/,%,++,--) Comparison Operators(==,!=,>,<,>=,<=)  Logical or Relational Operators(and,or,&&,||,!)  Assignment Operators(=,+=,-=,*=,/=,%=)  Conditional or Ternary Operators( ?: )
  • 15.
     if-else Statement if(condition) code to be executed if condition is true; else code to be executed if condition is false;
  • 16.
     elseif Statement if(condition) code to be executed if condition is true; elseif (condition) code to be executed if condition is true; else code to be executed if condition is false;
  • 17.
     Switch Statement switch(expression) { case label1: code to be executed if expression = label1; break; case label2: code to be executed if expression = label2; break; default: code to be executed if expression is different from above labels; }
  • 18.
     for Statement for(initialization; condition; updation) { code to be executed; }
  • 19.
     while Statement while(condition) { code to be executed; }
  • 20.
     do-while Statement do { codeto be executed; } while (condition);
  • 21.
     foreach Statement foreach(array as value) { code to be executed; }
  • 22.
     An arrayis a data structure that stores one or more type of values in a single variable.  Types of Arrays: i. Numeric Array ii. Associative Array iii. Multidimensional Array
  • 23.
     These arrayscan store numbers, strings and any object.  Here we have used array() function to create array.
  • 24.
     Associative arraywill have their index as string so that you can establish a strong association between key and values. Creating Array: $array_name=array(“str1”=>value1, “str2”=>value2, …… “strn”=>valuen); Accessing Array Elements: $array_name[‘str1’];
  • 25.
     A multi-dimensionalarray each element in the main array can also be an array and each element in the sub-array can be an array and so on.
  • 26.
     A functionis a piece of code which takes one or more input in the form of parameter and does some processing and returns a value.  Creating Function function function_name(parameters list) { /* Code Here */ }  Calling Function function_name(parameters list);
  • 27.
     Cookies aretext files stored on the client computer and they are kept of use tracking purpose.  There are 3 steps involved in identifying returning users: i. Server script sends a set of cookies to the browser. ii. Browser stores this information on local machine for future use. iii. Next time, when the browser sends any request to the web server, it sends those cookies information to the server and server uses that information to identify the user.
  • 28.
     PHP providedsetcookie() function to set a cookie. setcookie(name,value,expire,path,domain,security);  To access cookies, use either $_COOKIE[name] or $HTTP_COOKIE_VARS[name] variables.  You can use isset() function to check if a cookie is set or not.
  • 29.
    CONNECTING TO MYSQLDATABASE Opening a Database Connection connection mysql_connect(dbserver, user, password, new_link, client_flag); Closing Database Connection bool mysql_close(resource $link_identifier);
  • 30.
    Selecting a Database $retval=boolmysql_select_db(dn_name,connection); Creating a Database/Executing Query bool mysql_query(sql,connection); Retrieving Data from Database mysql_fetch_array($retval, type_array); mysql_fetch_assoc($retval);