SlideShare a Scribd company logo
Introduction to PHP
•Server-Side Scripting
•MYSQL
•PHP
•Apache
•Variables
•Control Structure
•Looping
A “script” is a collection of program or sequence of
instructions that is interpreted or carried out by
another program rather than by the computer
processor.
Client-side
Server-side
In server-side scripting, (such as PHP, ASP) the script
is processed by the server Like:
Apache, ColdFusion, ISAPI and Microsoft's IIS on
Windows.
Client-side scripting such as JavaScript runs on the
web browser.
 Advantages of Server-Side Scripting

 Dynamic content.
 Computational capability.
 Database and file system access.
 Network access (from the server only).
 Built-in libraries and functions.
 Known platform for execution (as opposed to client-

side, where the platform is uncontrolled.)
 Security improvements
• PHP stands for PHP: Hypertext Preprocessor
• Developed by Rasmus Lerdorf in 1994
• It is a powerful server-side scripting language for

creating dynamic and interactive websites.
• It is an open source software, which is widely
used to develop dynamic websites.
• It is an efficient alternative to competitors such as
Microsoft's ASP.
• PHP is perfectly suited for Web development and

can be embedded directly into the HTML code.
• The PHP syntax is very similar to JavaScript, Perl
and C.
• PHP is often used together with Apache (web
server) on various operating systems. It also
supports ISAPI and can be used with Microsoft's
IIS on Windows.
• PHP supports many databases
(MySQL, Informix, Oracle, Sybase, Solid, Postgre
SQL, Generic ODBC, etc.)
• What is a PHP File?
• PHP files have a file extension of

".php", ".php3", or ".phtml"
• PHP files can contain text, HTML tags and scripts
• PHP files are returned to the browser as plain
HTML
What you need to develop PHP Application:
• Install Apache (or IIS) on your own server, install
PHP, and MySQL
• OR
• Install Wampserver2 (a bundle of
PHP, Apache, and MySql server) on your own
server/machine
• When a PHP document is requested of a

server, the server will send the document first to a
PHP processor
• Two modes of operation
– Copy mode in which plain HTML is copied to the

output
– Interpret mode in which PHP code is interpreted
and the output from that code sent to output
– The client never sees PHP code, only the output
produced by the code
• PHP statements are terminated with semicolons ;
• Curly braces, { } are used to create compound statements
• Variables cannot be defined in a compound statement

unless it is the body of a function
• PHP has typical scripting language characteristics
–
–
–
–

Dynamic typing, un-typed variables
Associative arrays
Pattern matching
Extensive libraries

• Primitives, Operations, Expressions
– Four scalar types: boolean, integer, double, string
– Two compound types: array, object
– Two special types: resource and NULL
• A PHP scripting block always starts with <?php and ends with

?>
<?php ……………. ?>
– Other options are:
1.
<? ……………… ?>
2.
<script> ... </script>

• There are three basic statements to output text with PHP:

echo, print, and printf. Example:
echo 'This is a <b>test</b>!';
• Comments:
– #
– //
– /* . . . */
Basic PHP Syntax
 Inserting external files:
 PHP provides four functions that enable

you to insert code from external files:
include() or require() include_once()
or require_once() functions.
• E.g.
 include("table2.php");
– Included files start in copy mode
Example 1
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head> <title>Simple PHP Example</title>

<body>

<?php
echo "Hello Class of 2011. This is my first PHP Script";
echo "<br />";
print "<b><i>What have you learnt and how many friends have you
made?</i></b>";
echo "<br /><a href='PHP I-BSIC.ppt'>PHP BASIC</a>";

?>
</body>
</html>
PHP Variables
• Variables are used for storing values, such as

numbers, strings or function results, so that they can be
used many times in a script.
• All variables in PHP start with a $ sign symbol.
• Variables are assigned using the assignment operator "="
• Variable names are case sensitive in PHP: $name is not

the same as $NAME or $Name.
• In PHP a variable does not need to be declared before

being set.
• PHP is a Loosely Typed Language.
Strings in PHP
•
•
•

a string is a sequence of letters, symbols, characters and arithmetic values or
combination of all tied together in single or double quotes.
String literals are enclosed in single or double quotes
Example:
<?php
$sum = 20;
echo 'the sum is: $sum';
echo "<br />";
echo "the sum is: $sum";
echo "<br />";
echo '<input type="text" name="first_name" id="first_name">';
?>

–

Double quoted strings have escape sequences (such as /n or /r) interpreted
and variables interpolated (substituted)
– Single quoted strings have neither escape sequence interpretation nor variable
interpolation
– A literal $ sign in a double quoted string must be escaped with a backslash, 
– Double-quoted strings can cover multiple lines
PHP Function
 In php a function is a predefined set of

commands that are carried out when the function
is called.
 The real power of PHP comes from its functions.
 PHP has more than 700 built-in or predefine
functions for you to use.
Using Built-in Function
 Examples: Inserting external files:
 PHP provides four functions that enable you to insert code from external

files: include() or require() include_once() or require_once()
functions.
 A sample include file called add.php
<html> <body>
<?php
function add( $x, $y ) {
return $x + $y; }
?>
<h1>Welcome to my home page</h1>
<p>Some text</p>
</body> </html>

Using the include function
<?php
include('add.php');
echo add(2, 2); ?>
PHP Functions - Adding
parameters
 A parameter is just like a variable.
 The parameters are specified inside the parentheses.

Syntax:
<?php
function function_name(param_1, ...
, param_n)
{
statement_1;
statement_2;
...
statement_m;

?>

}

return return_value;
PHP Functions - Adding
parameters
 Functions can also be used to return values.
Example:



<html>
<body>








<?php
function add($x,$y)
{
$total = $x + $y;
return $total;
}




echo "1 + 16 = " . add(1,16);
?>




</body>
</html>
Control Structure
 Control structures are the building blocks of any

programming language. PHP provides all the
control structures that you may have encountered
anywhere. The syntax is the same as C or Perl.
 Making computers think has always been the
goal of the computer architect and the
programmer. Using control structures computers
can make simple decisions and when
programmed cleverly they can do some complex
things.
PHP Switch Statement
• If you want to select one of many blocks of code to be

executed, use the Switch statement.
• The switch statement is used to avoid long blocks of
if..elseif..else code.
Syntax
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 both
label1 and label2;
}
PHP Switch Statement















switch ($textcolor)
{
case "black":
echo "I'm black";
break;
case "blue":
echo "I'm blue";
break;
case "red":
echo "I'm red";
break;
default: // It must be something else
echo "too bad!!, I'm something else";
}
PHP Looping
• Looping statements in PHP are used to execute the

same block of code a specified number of times.
• In PHP we have the following looping statements:
– while - loops through a block of code if and as long as

a specified condition is true
– do...while - loops through a block of code once, and
then repeats the loop as long as a special condition is
true
– for - loops through a block of code a specified number
of times
– foreach - loops through a block of code for each
element in an array
The while Statement
Syntax
while (condition)
{
// statements

}

Example
<html> <head> <title>Let us count !!!</title></head>
<body>
<?php
$limit = 10;
echo "<h2> Let us count from 1 to $limit </h2><br />";
$count = 1;
while ($count <= $limit)
{
echo "counting $count of $limit <br>";
$count++;
}
?>
</body>
<html>
The do...while Statement
•

The do...while statement will execute a block of code at least once - it
then will repeat the loop as long as a condition is true.

Syntax
• do { code to be executed; } while (condition);









Example
<html> <body>
<?php
$i=0;
do { $i++; echo "The number is " . $i . "<br />"; }
while ($i<5);
?>
</body> </html>
PHP Arrays
 An array can store one or more values in a single

variable name.
 There are three different kind of arrays:
 Numeric array - An array with a numeric ID key
 Associative array - An array where each ID key is

associated with a value
 Multidimensional array - An array containing one
or more arrays
Numeric Array
• A numeric array stores each element with a numeric ID

key.
• There are different ways to create a numeric array:
Example 1
• In this example the ID key is automatically assigned:
• $names = array("Peter","Quagmire","Joe");
Example 2
• In this example we assign the ID key manually:
$names[0] = "Peter";
$names[1] = "Quagmire";
$names[2] = "Joe";
Associative Arrays
• Each ID key is associated with a value.
• When storing data about specific named values, a

numerical array is not always the best way to do it.
• There are two ways of creating Associative Array:
Example 1
• $ages =
array("Peter"=>32, "Quagmire"=>30, "Joe"=>34);
Example 2
• $ages['Peter'] = "32"; $ages['Quagmire'] = "30";
$ages['Joe'] = "34";
Multidimensional Arrays
• In a multidimensional 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.
• Example 1
• with automatically assigned ID keys:

$families = array
( "Griffin"=>array
( "Peter", "Lois", "Megan" ),

"Quagmire"=>array
( "Glenn" ),

"Brown"=>array
( "Cleveland", "Loretta", "Junior" )

);
Multidimensional Arrays



Example 2:
The array above would look like this if written to the output:





Array
(
[Griffin] => Array
 (
 [0] => Peter
 [1] => Lois
 [2] => Megan
 )
[Quagmire] => Array
 (
 [0] => Glenn
 )
[Brown] => Array
 (
 [0] => Cleveland
 [1] => Loretta
 [2] => Junior )
 )





•

displaying a single value from the array above:



echo "Is " . $families['Griffin'][2] . " a part of the Griffin family?";

More Related Content

PPT
PHP - DataType,Variable,Constant,Operators,Array,Include and require
TheCreativedev Blog
 
PPTX
Operators php
Chandni Pm
 
PDF
Operators in PHP
Vineet Kumar Saini
 
PDF
Data Types In PHP
Mark Niebergall
 
PPT
PHP variables
Siddique Ibrahim
 
PPSX
Php using variables-operators
Khem Puthea
 
PPT
Basic PHP
Todd Barber
 
PDF
Functions in PHP
Vineet Kumar Saini
 
PHP - DataType,Variable,Constant,Operators,Array,Include and require
TheCreativedev Blog
 
Operators php
Chandni Pm
 
Operators in PHP
Vineet Kumar Saini
 
Data Types In PHP
Mark Niebergall
 
PHP variables
Siddique Ibrahim
 
Php using variables-operators
Khem Puthea
 
Basic PHP
Todd Barber
 
Functions in PHP
Vineet Kumar Saini
 

What's hot (20)

PPT
Php i basic chapter 3
Muhamad Al Imran
 
PDF
Php Tutorials for Beginners
Vineet Kumar Saini
 
PPTX
Basic of PHP
Nisa Soomro
 
PPTX
Lesson 4 constant
MLG College of Learning, Inc
 
PPT
Class 3 - PHP Functions
Ahmed Swilam
 
PPTX
Learn PHP Basics
McSoftsis
 
PPT
Class 2 - Introduction to PHP
Ahmed Swilam
 
ODP
Php variables (english)
Mahmoud Masih Tehrani
 
PPTX
PHP Basics
Bhaktaraz Bhatta
 
PPTX
Lesson 2 php data types
MLG College of Learning, Inc
 
PPTX
php basics
Anmol Paul
 
PPTX
PHP Powerpoint -- Teach PHP with this
Ian Macali
 
ODP
PHP Basic
Yoeung Vibol
 
ODP
PHP Web Programming
Muthuselvam RS
 
PPT
Introduction to PHP
Jussi Pohjolainen
 
PPTX
PHP Basics
Muthuganesh S
 
PPT
PHP Workshop Notes
Pamela Fox
 
PPTX
Php introduction
Pratik Patel
 
PPT
Php Chapter 2 3 Training
Chris Chubb
 
Php i basic chapter 3
Muhamad Al Imran
 
Php Tutorials for Beginners
Vineet Kumar Saini
 
Basic of PHP
Nisa Soomro
 
Lesson 4 constant
MLG College of Learning, Inc
 
Class 3 - PHP Functions
Ahmed Swilam
 
Learn PHP Basics
McSoftsis
 
Class 2 - Introduction to PHP
Ahmed Swilam
 
Php variables (english)
Mahmoud Masih Tehrani
 
PHP Basics
Bhaktaraz Bhatta
 
Lesson 2 php data types
MLG College of Learning, Inc
 
php basics
Anmol Paul
 
PHP Powerpoint -- Teach PHP with this
Ian Macali
 
PHP Basic
Yoeung Vibol
 
PHP Web Programming
Muthuselvam RS
 
Introduction to PHP
Jussi Pohjolainen
 
PHP Basics
Muthuganesh S
 
PHP Workshop Notes
Pamela Fox
 
Php introduction
Pratik Patel
 
Php Chapter 2 3 Training
Chris Chubb
 
Ad

Viewers also liked (15)

PPT
Charting solutions evaluation-1
krishnasasidharan
 
PPTX
Pathos presentation
Kassia Waggoner
 
PDF
Double cartridge seal
American Seal and Packing
 
PPT
Liquid properties
American Seal and Packing
 
PPT
Internet by Javiera.
bargenperrin
 
PPT
Ci powerpoint
tanyacork
 
PPTX
Best spring classes in navi mumbai,spring course-provider in navi-mumbai,spri...
anshkhurana01
 
DOC
adarsh resume
adarathi
 
PDF
Aix admin-course-provider-navi-mumbai
anshkhurana01
 
PPT
E&C Вrodaband 2015 Власть перезагрузка создание коммуникациинной платформы дл...
Expert and Consulting (EnC)
 
PPT
05php
anshkhurana01
 
PDF
Introduction to BluWrap
BluWrap
 
PPTX
Unit 5 proses 1 function and ability group 5
Claudia Waloni
 
PPTX
Siebel training-course-navi-mumbai-siebel-course-provider-navi-mumbai
anshkhurana01
 
Charting solutions evaluation-1
krishnasasidharan
 
Pathos presentation
Kassia Waggoner
 
Double cartridge seal
American Seal and Packing
 
Liquid properties
American Seal and Packing
 
Internet by Javiera.
bargenperrin
 
Ci powerpoint
tanyacork
 
Best spring classes in navi mumbai,spring course-provider in navi-mumbai,spri...
anshkhurana01
 
adarsh resume
adarathi
 
Aix admin-course-provider-navi-mumbai
anshkhurana01
 
E&C Вrodaband 2015 Власть перезагрузка создание коммуникациинной платформы дл...
Expert and Consulting (EnC)
 
Introduction to BluWrap
BluWrap
 
Unit 5 proses 1 function and ability group 5
Claudia Waloni
 
Siebel training-course-navi-mumbai-siebel-course-provider-navi-mumbai
anshkhurana01
 
Ad

Similar to Php mysql classes in navi-mumbai,php-mysql course provider-in-navi-mumbai,best php-mysql classes in navi-mumbai (20)

PPT
Php i basic chapter 3 (mardhiah kamaludin's conflicted copy 2013-04-23)
Muhamad Al Imran
 
PDF
Materi Dasar PHP
Robby Firmansyah
 
PPT
PHP MySQL Workshop - facehook
Shashank Skills Academy
 
PDF
Hsc IT 5. Server-Side Scripting (PHP).pdf
AAFREEN SHAIKH
 
PPTX
PHP ITCS 323
Sleepy Head
 
PPT
Php i basic chapter 3 (afifah rosli's conflicted copy 2013-04-23)
Muhamad Al Imran
 
PPT
Php i basic chapter 3 (syahir chaer's conflicted copy 2013-04-22)
Muhamad Al Imran
 
PPTX
PHP from soup to nuts Course Deck
rICh morrow
 
PPTX
php Chapter 1.pptx
HambaAbebe2
 
PDF
Introduction to PHP - Basics of PHP
wahidullah mudaser
 
PPT
Php Tutorial
SHARANBAJWA
 
PPTX
Lecture 6: Introduction to PHP and Mysql .pptx
AOmaAli
 
PPT
PHP - Introduction to PHP Fundamentals
Vibrant Technologies & Computers
 
PPTX
Introduction to php
Taha Malampatti
 
PDF
UNIT4.pdf php basic programming for begginers
AAFREEN SHAIKH
 
PPTX
INTRODUCTION ON PHP - SERVER SIDE SCRIPTING LANGUAGE
PRIYADARSINIK3
 
PPTX
Php unit i
BagavathiLakshmi
 
PPTX
introduction to php and its uses in daily
vishal choudhary
 
Php i basic chapter 3 (mardhiah kamaludin's conflicted copy 2013-04-23)
Muhamad Al Imran
 
Materi Dasar PHP
Robby Firmansyah
 
PHP MySQL Workshop - facehook
Shashank Skills Academy
 
Hsc IT 5. Server-Side Scripting (PHP).pdf
AAFREEN SHAIKH
 
PHP ITCS 323
Sleepy Head
 
Php i basic chapter 3 (afifah rosli's conflicted copy 2013-04-23)
Muhamad Al Imran
 
Php i basic chapter 3 (syahir chaer's conflicted copy 2013-04-22)
Muhamad Al Imran
 
PHP from soup to nuts Course Deck
rICh morrow
 
php Chapter 1.pptx
HambaAbebe2
 
Introduction to PHP - Basics of PHP
wahidullah mudaser
 
Php Tutorial
SHARANBAJWA
 
Lecture 6: Introduction to PHP and Mysql .pptx
AOmaAli
 
PHP - Introduction to PHP Fundamentals
Vibrant Technologies & Computers
 
Introduction to php
Taha Malampatti
 
UNIT4.pdf php basic programming for begginers
AAFREEN SHAIKH
 
INTRODUCTION ON PHP - SERVER SIDE SCRIPTING LANGUAGE
PRIYADARSINIK3
 
Php unit i
BagavathiLakshmi
 
introduction to php and its uses in daily
vishal choudhary
 

More from anshkhurana01 (15)

DOCX
sas-course-provider-navi-mumbai-sas-training-navi-mumbai-sas-classes-navi-mumbai
anshkhurana01
 
TXT
Sajid
anshkhurana01
 
PPTX
Aix admin-course-provider-navi-mumbai
anshkhurana01
 
PPTX
Websphere application-server-training-course-navi-mumbai-websphere-applicatio...
anshkhurana01
 
PPTX
Shell scripting-training-course-navi-mumbai-shell-scripting-course-provider-n...
anshkhurana01
 
PDF
Linux training-course-navi-mumbai-linux-course-provider-navi-mumbai
anshkhurana01
 
PDF
Java j2ee-training-course-navi-mumbai-java-j2ee-course-provider-navi-mumbai
anshkhurana01
 
PDF
Siebel training-course-navi-mumbai-siebel-course-provider-navi-mumbai
anshkhurana01
 
PDF
Tibco training-course-navi-mumbai-tibco-course-provider-navi-mumbai
anshkhurana01
 
PDF
Embeddedsystem training-course-navi-mumbai-embeddedsysteml-course-provider-na...
anshkhurana01
 
PDF
Mainframe training-course-navi-mumbai-mainframe-course-provider-navi-mumbai
anshkhurana01
 
PDF
Sas training-course-navi-mumbai-sas-course-provider-navi-mumbai
anshkhurana01
 
PDF
Linux training-course-navi-mumbai-linux-course-provider-navi-mumbai
anshkhurana01
 
PPT
Mysql classes in navi-mumbai,mysql course-provider-in-navi-mumbai
anshkhurana01
 
PPTX
Best java courses in navi mumbai best classes for java in navi mumbai-java cl...
anshkhurana01
 
sas-course-provider-navi-mumbai-sas-training-navi-mumbai-sas-classes-navi-mumbai
anshkhurana01
 
Aix admin-course-provider-navi-mumbai
anshkhurana01
 
Websphere application-server-training-course-navi-mumbai-websphere-applicatio...
anshkhurana01
 
Shell scripting-training-course-navi-mumbai-shell-scripting-course-provider-n...
anshkhurana01
 
Linux training-course-navi-mumbai-linux-course-provider-navi-mumbai
anshkhurana01
 
Java j2ee-training-course-navi-mumbai-java-j2ee-course-provider-navi-mumbai
anshkhurana01
 
Siebel training-course-navi-mumbai-siebel-course-provider-navi-mumbai
anshkhurana01
 
Tibco training-course-navi-mumbai-tibco-course-provider-navi-mumbai
anshkhurana01
 
Embeddedsystem training-course-navi-mumbai-embeddedsysteml-course-provider-na...
anshkhurana01
 
Mainframe training-course-navi-mumbai-mainframe-course-provider-navi-mumbai
anshkhurana01
 
Sas training-course-navi-mumbai-sas-course-provider-navi-mumbai
anshkhurana01
 
Linux training-course-navi-mumbai-linux-course-provider-navi-mumbai
anshkhurana01
 
Mysql classes in navi-mumbai,mysql course-provider-in-navi-mumbai
anshkhurana01
 
Best java courses in navi mumbai best classes for java in navi mumbai-java cl...
anshkhurana01
 

Recently uploaded (20)

PPTX
ACUTE NASOPHARYNGITIS. pptx
AneetaSharma15
 
PDF
What is CFA?? Complete Guide to the Chartered Financial Analyst Program
sp4989653
 
PDF
Module 3: Health Systems Tutorial Slides S2 2025
Jonathan Hallett
 
PDF
2.Reshaping-Indias-Political-Map.ppt/pdf/8th class social science Exploring S...
Sandeep Swamy
 
PPTX
Dakar Framework Education For All- 2000(Act)
santoshmohalik1
 
PPTX
HISTORY COLLECTION FOR PSYCHIATRIC PATIENTS.pptx
PoojaSen20
 
PPTX
NOI Hackathon - Summer Edition - GreenThumber.pptx
MartinaBurlando1
 
DOCX
SAROCES Action-Plan FOR ARAL PROGRAM IN DEPED
Levenmartlacuna1
 
PPTX
Odoo 18 Sales_ Managing Quotation Validity
Celine George
 
DOCX
UPPER GASTRO INTESTINAL DISORDER.docx
BANDITA PATRA
 
PPTX
Open Quiz Monsoon Mind Game Final Set.pptx
Sourav Kr Podder
 
PDF
Review of Related Literature & Studies.pdf
Thelma Villaflores
 
PPTX
Introduction and Scope of Bichemistry.pptx
shantiyogi
 
PDF
Landforms and landscapes data surprise preview
jpinnuck
 
PPTX
How to Manage Leads in Odoo 18 CRM - Odoo Slides
Celine George
 
PPTX
Skill Development Program For Physiotherapy Students by SRY.pptx
Prof.Dr.Y.SHANTHOSHRAJA MPT Orthopedic., MSc Microbiology
 
PPTX
IMMUNIZATION PROGRAMME pptx
AneetaSharma15
 
PDF
High Ground Student Revision Booklet Preview
jpinnuck
 
PPTX
PREVENTIVE PEDIATRIC. pptx
AneetaSharma15
 
PDF
3.The-Rise-of-the-Marathas.pdfppt/pdf/8th class social science Exploring Soci...
Sandeep Swamy
 
ACUTE NASOPHARYNGITIS. pptx
AneetaSharma15
 
What is CFA?? Complete Guide to the Chartered Financial Analyst Program
sp4989653
 
Module 3: Health Systems Tutorial Slides S2 2025
Jonathan Hallett
 
2.Reshaping-Indias-Political-Map.ppt/pdf/8th class social science Exploring S...
Sandeep Swamy
 
Dakar Framework Education For All- 2000(Act)
santoshmohalik1
 
HISTORY COLLECTION FOR PSYCHIATRIC PATIENTS.pptx
PoojaSen20
 
NOI Hackathon - Summer Edition - GreenThumber.pptx
MartinaBurlando1
 
SAROCES Action-Plan FOR ARAL PROGRAM IN DEPED
Levenmartlacuna1
 
Odoo 18 Sales_ Managing Quotation Validity
Celine George
 
UPPER GASTRO INTESTINAL DISORDER.docx
BANDITA PATRA
 
Open Quiz Monsoon Mind Game Final Set.pptx
Sourav Kr Podder
 
Review of Related Literature & Studies.pdf
Thelma Villaflores
 
Introduction and Scope of Bichemistry.pptx
shantiyogi
 
Landforms and landscapes data surprise preview
jpinnuck
 
How to Manage Leads in Odoo 18 CRM - Odoo Slides
Celine George
 
Skill Development Program For Physiotherapy Students by SRY.pptx
Prof.Dr.Y.SHANTHOSHRAJA MPT Orthopedic., MSc Microbiology
 
IMMUNIZATION PROGRAMME pptx
AneetaSharma15
 
High Ground Student Revision Booklet Preview
jpinnuck
 
PREVENTIVE PEDIATRIC. pptx
AneetaSharma15
 
3.The-Rise-of-the-Marathas.pdfppt/pdf/8th class social science Exploring Soci...
Sandeep Swamy
 

Php mysql classes in navi-mumbai,php-mysql course provider-in-navi-mumbai,best php-mysql classes in navi-mumbai

  • 1. Introduction to PHP •Server-Side Scripting •MYSQL •PHP •Apache •Variables •Control Structure •Looping
  • 2. A “script” is a collection of program or sequence of instructions that is interpreted or carried out by another program rather than by the computer processor. Client-side Server-side In server-side scripting, (such as PHP, ASP) the script is processed by the server Like: Apache, ColdFusion, ISAPI and Microsoft's IIS on Windows. Client-side scripting such as JavaScript runs on the web browser.
  • 3.  Advantages of Server-Side Scripting  Dynamic content.  Computational capability.  Database and file system access.  Network access (from the server only).  Built-in libraries and functions.  Known platform for execution (as opposed to client- side, where the platform is uncontrolled.)  Security improvements
  • 4. • PHP stands for PHP: Hypertext Preprocessor • Developed by Rasmus Lerdorf in 1994 • It is a powerful server-side scripting language for creating dynamic and interactive websites. • It is an open source software, which is widely used to develop dynamic websites. • It is an efficient alternative to competitors such as Microsoft's ASP.
  • 5. • PHP is perfectly suited for Web development and can be embedded directly into the HTML code. • The PHP syntax is very similar to JavaScript, Perl and C. • PHP is often used together with Apache (web server) on various operating systems. It also supports ISAPI and can be used with Microsoft's IIS on Windows. • PHP supports many databases (MySQL, Informix, Oracle, Sybase, Solid, Postgre SQL, Generic ODBC, etc.)
  • 6. • What is a PHP File? • PHP files have a file extension of ".php", ".php3", or ".phtml" • PHP files can contain text, HTML tags and scripts • PHP files are returned to the browser as plain HTML
  • 7. What you need to develop PHP Application: • Install Apache (or IIS) on your own server, install PHP, and MySQL • OR • Install Wampserver2 (a bundle of PHP, Apache, and MySql server) on your own server/machine
  • 8. • When a PHP document is requested of a server, the server will send the document first to a PHP processor • Two modes of operation – Copy mode in which plain HTML is copied to the output – Interpret mode in which PHP code is interpreted and the output from that code sent to output – The client never sees PHP code, only the output produced by the code
  • 9. • PHP statements are terminated with semicolons ; • Curly braces, { } are used to create compound statements • Variables cannot be defined in a compound statement unless it is the body of a function • PHP has typical scripting language characteristics – – – – Dynamic typing, un-typed variables Associative arrays Pattern matching Extensive libraries • Primitives, Operations, Expressions – Four scalar types: boolean, integer, double, string – Two compound types: array, object – Two special types: resource and NULL
  • 10. • A PHP scripting block always starts with <?php and ends with ?> <?php ……………. ?> – Other options are: 1. <? ……………… ?> 2. <script> ... </script> • There are three basic statements to output text with PHP: echo, print, and printf. Example: echo 'This is a <b>test</b>!'; • Comments: – # – // – /* . . . */
  • 11. Basic PHP Syntax  Inserting external files:  PHP provides four functions that enable you to insert code from external files: include() or require() include_once() or require_once() functions. • E.g.  include("table2.php"); – Included files start in copy mode
  • 12. Example 1 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>Simple PHP Example</title> <body> <?php echo "Hello Class of 2011. This is my first PHP Script"; echo "<br />"; print "<b><i>What have you learnt and how many friends have you made?</i></b>"; echo "<br /><a href='PHP I-BSIC.ppt'>PHP BASIC</a>"; ?> </body> </html>
  • 13. PHP Variables • Variables are used for storing values, such as numbers, strings or function results, so that they can be used many times in a script. • All variables in PHP start with a $ sign symbol. • Variables are assigned using the assignment operator "=" • Variable names are case sensitive in PHP: $name is not the same as $NAME or $Name. • In PHP a variable does not need to be declared before being set. • PHP is a Loosely Typed Language.
  • 14. Strings in PHP • • • a string is a sequence of letters, symbols, characters and arithmetic values or combination of all tied together in single or double quotes. String literals are enclosed in single or double quotes Example: <?php $sum = 20; echo 'the sum is: $sum'; echo "<br />"; echo "the sum is: $sum"; echo "<br />"; echo '<input type="text" name="first_name" id="first_name">'; ?> – Double quoted strings have escape sequences (such as /n or /r) interpreted and variables interpolated (substituted) – Single quoted strings have neither escape sequence interpretation nor variable interpolation – A literal $ sign in a double quoted string must be escaped with a backslash, – Double-quoted strings can cover multiple lines
  • 15. PHP Function  In php a function is a predefined set of commands that are carried out when the function is called.  The real power of PHP comes from its functions.  PHP has more than 700 built-in or predefine functions for you to use.
  • 16. Using Built-in Function  Examples: Inserting external files:  PHP provides four functions that enable you to insert code from external files: include() or require() include_once() or require_once() functions.  A sample include file called add.php <html> <body> <?php function add( $x, $y ) { return $x + $y; } ?> <h1>Welcome to my home page</h1> <p>Some text</p> </body> </html> Using the include function <?php include('add.php'); echo add(2, 2); ?>
  • 17. PHP Functions - Adding parameters  A parameter is just like a variable.  The parameters are specified inside the parentheses. Syntax: <?php function function_name(param_1, ... , param_n) { statement_1; statement_2; ... statement_m; ?> } return return_value;
  • 18. PHP Functions - Adding parameters  Functions can also be used to return values. Example:   <html> <body>       <?php function add($x,$y) { $total = $x + $y; return $total; }   echo "1 + 16 = " . add(1,16); ?>   </body> </html>
  • 19. Control Structure  Control structures are the building blocks of any programming language. PHP provides all the control structures that you may have encountered anywhere. The syntax is the same as C or Perl.  Making computers think has always been the goal of the computer architect and the programmer. Using control structures computers can make simple decisions and when programmed cleverly they can do some complex things.
  • 20. PHP Switch Statement • If you want to select one of many blocks of code to be executed, use the Switch statement. • The switch statement is used to avoid long blocks of if..elseif..else code. Syntax 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 both label1 and label2; }
  • 21. PHP Switch Statement               switch ($textcolor) { case "black": echo "I'm black"; break; case "blue": echo "I'm blue"; break; case "red": echo "I'm red"; break; default: // It must be something else echo "too bad!!, I'm something else"; }
  • 22. PHP Looping • Looping statements in PHP are used to execute the same block of code a specified number of times. • In PHP we have the following looping statements: – while - loops through a block of code if and as long as a specified condition is true – do...while - loops through a block of code once, and then repeats the loop as long as a special condition is true – for - loops through a block of code a specified number of times – foreach - loops through a block of code for each element in an array
  • 23. The while Statement Syntax while (condition) { // statements } Example <html> <head> <title>Let us count !!!</title></head> <body> <?php $limit = 10; echo "<h2> Let us count from 1 to $limit </h2><br />"; $count = 1; while ($count <= $limit) { echo "counting $count of $limit <br>"; $count++; } ?> </body> <html>
  • 24. The do...while Statement • The do...while statement will execute a block of code at least once - it then will repeat the loop as long as a condition is true. Syntax • do { code to be executed; } while (condition);         Example <html> <body> <?php $i=0; do { $i++; echo "The number is " . $i . "<br />"; } while ($i<5); ?> </body> </html>
  • 25. PHP Arrays  An array can store one or more values in a single variable name.  There are three different kind of arrays:  Numeric array - An array with a numeric ID key  Associative array - An array where each ID key is associated with a value  Multidimensional array - An array containing one or more arrays
  • 26. Numeric Array • A numeric array stores each element with a numeric ID key. • There are different ways to create a numeric array: Example 1 • In this example the ID key is automatically assigned: • $names = array("Peter","Quagmire","Joe"); Example 2 • In this example we assign the ID key manually: $names[0] = "Peter"; $names[1] = "Quagmire"; $names[2] = "Joe";
  • 27. Associative Arrays • Each ID key is associated with a value. • When storing data about specific named values, a numerical array is not always the best way to do it. • There are two ways of creating Associative Array: Example 1 • $ages = array("Peter"=>32, "Quagmire"=>30, "Joe"=>34); Example 2 • $ages['Peter'] = "32"; $ages['Quagmire'] = "30"; $ages['Joe'] = "34";
  • 28. Multidimensional Arrays • In a multidimensional 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. • Example 1 • with automatically assigned ID keys: $families = array ( "Griffin"=>array ( "Peter", "Lois", "Megan" ), "Quagmire"=>array ( "Glenn" ), "Brown"=>array ( "Cleveland", "Loretta", "Junior" ) );
  • 29. Multidimensional Arrays   Example 2: The array above would look like this if written to the output:    Array ( [Griffin] => Array  (  [0] => Peter  [1] => Lois  [2] => Megan  ) [Quagmire] => Array  (  [0] => Glenn  ) [Brown] => Array  (  [0] => Cleveland  [1] => Loretta  [2] => Junior )  )   • displaying a single value from the array above:  echo "Is " . $families['Griffin'][2] . " a part of the Griffin family?";