SlideShare a Scribd company logo
VIJAY SHARMA
PHP TUTORIAL
PHP Programming
With
My SQL Connection
www.kumarvijaybaswa.blogspot.com
VIJAY SHARMA
PHP: The Basics
 Why PHP and MySQL?
VIJAY SHARMA
What Is PHP?
 PHP is the Web development language written by and for Web
developers.
 PHP stands for PHP: Hypertext Preprocessor. The product was
originally named Personal Home Page Tools, and many people still
think that’s what the acronym stands for. But as it expanded in scope,
a new and more appropriate name was selected by community vote.
PHP is currently in its fifth major rewrite, called PHP5 or just plain
PHP.
VIJAY SHARMA
Server-Side Scripting
 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.
VIJAY SHARMA
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
VIJAY SHARMA
INTRODUCTION TO PHP
 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 and free to
download and use (PHP is FREE to download from the official
PHP resource: www.php.net).
 It is an efficient alternative to competitors such as Microsoft's
ASP.
VIJAY SHARMA
 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, PostgreSQL, Generic ODBC, etc.)
INTRODUCTION TO PHP
VIJAY SHARMA
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
INTRODUCTION TO PHP
VIJAY SHARMA
What you need to develop PHP Application:
 Install Apache (or IIS) on your own server, install PHP, and
MySQL
 Install Wampserver2 or XAMPP (a bundle of PHP,
Apache, and MySql server) on your own server/machine
INTRODUCTION TO PHP
VIJAY SHARMA
PHP Syntax
 A PHP scripting block always starts
with <?php and ends with ?>
 <?php……………. ?>
VIJAY SHARMA
Example simple html & php page
 PHP and HTML Code:
<html>
<head>
<title>My First PHP Page
</title>
</head>
<body>
<?php
echo "Hello World!";
?>
</body> </html>
VIJAY SHARMA
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.
VIJAY SHARMA
Example:
 <?php
 $var1 = 'PHP'; // Assigns a
value of 'PHP' to $var1
 $var2 = 5; // Assigns a value
of 5 to $var2
 $var3 = $var2 + 1; // Assigns
a value of 6 to $var3
 $var2 = $var1; // Assigns a
value of 'PHP' to $var2
 echo $var1; // Outputs 'PHP‘
 echo "<br />";
 echo $var2; // Outputs 'PHP'
 echo "<br />";
 echo $var3; // Outputs '6'
 echo "<br />";
 echo $var1 . ' rules!'; //
Outputs 'PHP rules!'
 echo "$var1 rules!"; //
Outputs 'PHP rules!'
 echo '$var1 rules!'; // Outputs
'$var1 rules!‘
 ?>
VIJAY SHARMA
VARIABLE SCOPE AND LIFETIME
 The scope of a variable defined within a
function is local to that function.
 A variable defined in the main body of code
has a global scope.
 If a function needs to use a variable that is
defined in the main body of the program, it
must reference it using the "global"
keyword, like this:
VIJAY SHARMA
Example:
 <?php
 function mul()
 {
 global $start;
 print "<tr>";
 for ($num=1; $num <= 10; $num++ )
 {
 $cell = $num * $start;
 print "<td> " . $cell . " </td>";
 }
 print "</tr>";
 }
 $start = 0;
VIJAY SHARMA
 print "<table border=1
cellpadding=3>";
 while ( $start <=10 )
 {
 mul();
 $start++;
 }
 print "</table>";
 ?>

More Related Content

PDF
Web Development Course: PHP lecture 1
Gheyath M. Othman
 
PDF
Php introduction
krishnapriya Tadepalli
 
PPTX
PHP
Steve Fort
 
PDF
Introduction to php
Anjan Banda
 
PDF
Php Tutorials for Beginners
Vineet Kumar Saini
 
PPTX
Php Tutorial
pratik tambekar
 
PPTX
Php
Shyam Khant
 
Web Development Course: PHP lecture 1
Gheyath M. Othman
 
Php introduction
krishnapriya Tadepalli
 
Introduction to php
Anjan Banda
 
Php Tutorials for Beginners
Vineet Kumar Saini
 
Php Tutorial
pratik tambekar
 

What's hot (20)

PPT
Beginners PHP Tutorial
alexjones89
 
PPT
Introduction To PHP
Shweta A
 
PPTX
Php technical presentation
dharmendra kumar dhakar
 
PPT
Chapter 02 php basic syntax
Dhani Ahmad
 
PDF
Web Development Course: PHP lecture 2
Gheyath M. Othman
 
PPT
01 Php Introduction
Geshan Manandhar
 
PPTX
Php.ppt
Nidhi mishra
 
PPT
PHP - Introduction to PHP AJAX
Vibrant Technologies & Computers
 
PDF
GET and POST in PHP
Vineet Kumar Saini
 
PDF
PHP Loops and PHP Forms
M.Zalmai Rahmani
 
PPTX
PL/SQL Fundamentals I
Nick Buytaert
 
PPT
PHP
sometech
 
PPTX
Form Handling using PHP
Nisa Soomro
 
ODP
Angular 6 - The Complete Guide
Sam Dias
 
PPT
Php Presentation
Manish Bothra
 
ODP
Introduction to jQuery
manugoel2003
 
PPTX
FYBSC IT Web Programming Unit IV PHP and MySQL
Arti Parab Academics
 
Beginners PHP Tutorial
alexjones89
 
Introduction To PHP
Shweta A
 
Php technical presentation
dharmendra kumar dhakar
 
Chapter 02 php basic syntax
Dhani Ahmad
 
Web Development Course: PHP lecture 2
Gheyath M. Othman
 
01 Php Introduction
Geshan Manandhar
 
Php.ppt
Nidhi mishra
 
PHP - Introduction to PHP AJAX
Vibrant Technologies & Computers
 
GET and POST in PHP
Vineet Kumar Saini
 
PHP Loops and PHP Forms
M.Zalmai Rahmani
 
PL/SQL Fundamentals I
Nick Buytaert
 
Form Handling using PHP
Nisa Soomro
 
Angular 6 - The Complete Guide
Sam Dias
 
Php Presentation
Manish Bothra
 
Introduction to jQuery
manugoel2003
 
FYBSC IT Web Programming Unit IV PHP and MySQL
Arti Parab Academics
 
Ad

Viewers also liked (11)

PPTX
Best Practices for Mobile Web Design
St. Petersburg College
 
PDF
Bca sem 6 php practicals 1to12
Hitesh Patel
 
ODP
Phpbasics And Php Framework
shivas
 
PPT
Joomla @ Barcamp4(Feb 08 Pune)
Amit Kumar Singh
 
PPTX
PHP framework difference
iScripts
 
PPT
SQL -PHP Tutorial
Information Technology
 
PPT
PHP Framework
celeroo
 
PPT
How to learn to build your own PHP framework
Dinh Pham
 
PDF
Tutorial php membuat Aplikasi Inventaris
Deka M Wildan
 
DOC
Tutorial Pembuatan Aplikasi Website Beserta Databasenya
RCH_98
 
Best Practices for Mobile Web Design
St. Petersburg College
 
Bca sem 6 php practicals 1to12
Hitesh Patel
 
Phpbasics And Php Framework
shivas
 
Joomla @ Barcamp4(Feb 08 Pune)
Amit Kumar Singh
 
PHP framework difference
iScripts
 
SQL -PHP Tutorial
Information Technology
 
PHP Framework
celeroo
 
How to learn to build your own PHP framework
Dinh Pham
 
Tutorial php membuat Aplikasi Inventaris
Deka M Wildan
 
Tutorial Pembuatan Aplikasi Website Beserta Databasenya
RCH_98
 
Ad

Similar to Php tutorial (20)

PPTX
PHP stand for PHP Hypertext Preprocessor
aaronbatac1
 
PPTX
PHP2An introduction to Gnome.pptx.j.pptx
JAYAVARSHINIJR
 
PPT
Introduction to PHP.ppt
SanthiNivas
 
PPTX
introduction to php and its uses in daily
vishal choudhary
 
PDF
PHP in Web development and Applications.pdf
VinayVitekari
 
PPTX
INTRODUCTION to php.pptx
priyanshupanchal8
 
PPTX
PHP ITCS 323
Sleepy Head
 
PPTX
php basic part one
jeweltutin
 
PPTX
lec1 (1).pptxkeoiwjwoijeoiwjeoijwoeijewoi
PedakotaPavankumar
 
PDF
Wt unit 4 server side technology-2
PUNE VIDYARTHI GRIHA'S COLLEGE OF ENGINEERING, NASHIK
 
PPTX
Introduction to php
Sush Singhaniya
 
PDF
Php tutorial(w3schools)
Arjun Shanka
 
PDF
Php tutorialw3schools
rasool noorpour
 
PPT
Intro to PHP for Students and professionals
cuyak
 
PPTX
Introduction to php
Taha Malampatti
 
PDF
Introduction to PHP - Basics of PHP
wahidullah mudaser
 
PPTX
Php intro
sana mateen
 
PDF
WT_PHP_PART1.pdf
HambardeAtharva
 
PHP stand for PHP Hypertext Preprocessor
aaronbatac1
 
PHP2An introduction to Gnome.pptx.j.pptx
JAYAVARSHINIJR
 
Introduction to PHP.ppt
SanthiNivas
 
introduction to php and its uses in daily
vishal choudhary
 
PHP in Web development and Applications.pdf
VinayVitekari
 
INTRODUCTION to php.pptx
priyanshupanchal8
 
PHP ITCS 323
Sleepy Head
 
php basic part one
jeweltutin
 
lec1 (1).pptxkeoiwjwoijeoiwjeoijwoeijewoi
PedakotaPavankumar
 
Wt unit 4 server side technology-2
PUNE VIDYARTHI GRIHA'S COLLEGE OF ENGINEERING, NASHIK
 
Introduction to php
Sush Singhaniya
 
Php tutorial(w3schools)
Arjun Shanka
 
Php tutorialw3schools
rasool noorpour
 
Intro to PHP for Students and professionals
cuyak
 
Introduction to php
Taha Malampatti
 
Introduction to PHP - Basics of PHP
wahidullah mudaser
 
Php intro
sana mateen
 
WT_PHP_PART1.pdf
HambardeAtharva
 

More from Computer Hardware & Trouble shooting (7)

Recently uploaded (20)

PPT
Python Programming Unit II Control Statements.ppt
CUO VEERANAN VEERANAN
 
PPTX
Presentation on Janskhiya sthirata kosh.
Ms Usha Vadhel
 
DOCX
UPPER GASTRO INTESTINAL DISORDER.docx
BANDITA PATRA
 
PPTX
IMMUNIZATION PROGRAMME pptx
AneetaSharma15
 
PDF
Module 3: Health Systems Tutorial Slides S2 2025
Jonathan Hallett
 
PPTX
Skill Development Program For Physiotherapy Students by SRY.pptx
Prof.Dr.Y.SHANTHOSHRAJA MPT Orthopedic., MSc Microbiology
 
PPTX
ACUTE NASOPHARYNGITIS. pptx
AneetaSharma15
 
PPTX
NOI Hackathon - Summer Edition - GreenThumber.pptx
MartinaBurlando1
 
PPTX
Congenital Hypothyroidism pptx
AneetaSharma15
 
PPTX
Odoo 18 Sales_ Managing Quotation Validity
Celine George
 
PPTX
PPTs-The Rise of Empiresghhhhhhhh (1).pptx
academysrusti114
 
PPTX
CARE OF UNCONSCIOUS PATIENTS .pptx
AneetaSharma15
 
PDF
What is CFA?? Complete Guide to the Chartered Financial Analyst Program
sp4989653
 
PDF
Arihant Class 10 All in One Maths full pdf
sajal kumar
 
PDF
1.Natural-Resources-and-Their-Use.ppt pdf /8th class social science Exploring...
Sandeep Swamy
 
PPTX
How to Manage Leads in Odoo 18 CRM - Odoo Slides
Celine George
 
PPTX
PREVENTIVE PEDIATRIC. pptx
AneetaSharma15
 
PDF
High Ground Student Revision Booklet Preview
jpinnuck
 
PPTX
Open Quiz Monsoon Mind Game Prelims.pptx
Sourav Kr Podder
 
PDF
2.Reshaping-Indias-Political-Map.ppt/pdf/8th class social science Exploring S...
Sandeep Swamy
 
Python Programming Unit II Control Statements.ppt
CUO VEERANAN VEERANAN
 
Presentation on Janskhiya sthirata kosh.
Ms Usha Vadhel
 
UPPER GASTRO INTESTINAL DISORDER.docx
BANDITA PATRA
 
IMMUNIZATION PROGRAMME pptx
AneetaSharma15
 
Module 3: Health Systems Tutorial Slides S2 2025
Jonathan Hallett
 
Skill Development Program For Physiotherapy Students by SRY.pptx
Prof.Dr.Y.SHANTHOSHRAJA MPT Orthopedic., MSc Microbiology
 
ACUTE NASOPHARYNGITIS. pptx
AneetaSharma15
 
NOI Hackathon - Summer Edition - GreenThumber.pptx
MartinaBurlando1
 
Congenital Hypothyroidism pptx
AneetaSharma15
 
Odoo 18 Sales_ Managing Quotation Validity
Celine George
 
PPTs-The Rise of Empiresghhhhhhhh (1).pptx
academysrusti114
 
CARE OF UNCONSCIOUS PATIENTS .pptx
AneetaSharma15
 
What is CFA?? Complete Guide to the Chartered Financial Analyst Program
sp4989653
 
Arihant Class 10 All in One Maths full pdf
sajal kumar
 
1.Natural-Resources-and-Their-Use.ppt pdf /8th class social science Exploring...
Sandeep Swamy
 
How to Manage Leads in Odoo 18 CRM - Odoo Slides
Celine George
 
PREVENTIVE PEDIATRIC. pptx
AneetaSharma15
 
High Ground Student Revision Booklet Preview
jpinnuck
 
Open Quiz Monsoon Mind Game Prelims.pptx
Sourav Kr Podder
 
2.Reshaping-Indias-Political-Map.ppt/pdf/8th class social science Exploring S...
Sandeep Swamy
 

Php tutorial

  • 1. VIJAY SHARMA PHP TUTORIAL PHP Programming With My SQL Connection www.kumarvijaybaswa.blogspot.com
  • 2. VIJAY SHARMA PHP: The Basics  Why PHP and MySQL?
  • 3. VIJAY SHARMA What Is PHP?  PHP is the Web development language written by and for Web developers.  PHP stands for PHP: Hypertext Preprocessor. The product was originally named Personal Home Page Tools, and many people still think that’s what the acronym stands for. But as it expanded in scope, a new and more appropriate name was selected by community vote. PHP is currently in its fifth major rewrite, called PHP5 or just plain PHP.
  • 4. VIJAY SHARMA Server-Side Scripting  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.
  • 5. VIJAY SHARMA 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
  • 6. VIJAY SHARMA INTRODUCTION TO PHP  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 and free to download and use (PHP is FREE to download from the official PHP resource: www.php.net).  It is an efficient alternative to competitors such as Microsoft's ASP.
  • 7. VIJAY SHARMA  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, PostgreSQL, Generic ODBC, etc.) INTRODUCTION TO PHP
  • 8. VIJAY SHARMA 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 INTRODUCTION TO PHP
  • 9. VIJAY SHARMA What you need to develop PHP Application:  Install Apache (or IIS) on your own server, install PHP, and MySQL  Install Wampserver2 or XAMPP (a bundle of PHP, Apache, and MySql server) on your own server/machine INTRODUCTION TO PHP
  • 10. VIJAY SHARMA PHP Syntax  A PHP scripting block always starts with <?php and ends with ?>  <?php……………. ?>
  • 11. VIJAY SHARMA Example simple html & php page  PHP and HTML Code: <html> <head> <title>My First PHP Page </title> </head> <body> <?php echo "Hello World!"; ?> </body> </html>
  • 12. VIJAY SHARMA 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.
  • 13. VIJAY SHARMA Example:  <?php  $var1 = 'PHP'; // Assigns a value of 'PHP' to $var1  $var2 = 5; // Assigns a value of 5 to $var2  $var3 = $var2 + 1; // Assigns a value of 6 to $var3  $var2 = $var1; // Assigns a value of 'PHP' to $var2  echo $var1; // Outputs 'PHP‘  echo "<br />";  echo $var2; // Outputs 'PHP'  echo "<br />";  echo $var3; // Outputs '6'  echo "<br />";  echo $var1 . ' rules!'; // Outputs 'PHP rules!'  echo "$var1 rules!"; // Outputs 'PHP rules!'  echo '$var1 rules!'; // Outputs '$var1 rules!‘  ?>
  • 14. VIJAY SHARMA VARIABLE SCOPE AND LIFETIME  The scope of a variable defined within a function is local to that function.  A variable defined in the main body of code has a global scope.  If a function needs to use a variable that is defined in the main body of the program, it must reference it using the "global" keyword, like this:
  • 15. VIJAY SHARMA Example:  <?php  function mul()  {  global $start;  print "<tr>";  for ($num=1; $num <= 10; $num++ )  {  $cell = $num * $start;  print "<td> " . $cell . " </td>";  }  print "</tr>";  }  $start = 0;
  • 16. VIJAY SHARMA  print "<table border=1 cellpadding=3>";  while ( $start <=10 )  {  mul();  $start++;  }  print "</table>";  ?>