SlideShare a Scribd company logo
PHP Basic
 Mandakini Kumari
 22 July 2012
   nd
 http://www.slideshare.net/mandakinikumari
                         Mandakini
                     Ayushi Infotech
Overview
A Brief History
What is PHP
Why PHP
PHP Stack
PHP Syntax
Variables
PHP String
PHP Operators
Overview
PHP Arrays
PHP If...Else
PHP Switch
PHP While
For Loop
Foreach
Function
Form,Get,Post
Overview
Object
Database Connection
Database Query
Sessions & Cookies
A brief history
• Created by Rasmus Lerdorf in 1995
• PHP: Hypertext Preprocessor
• PHP interpreters available on 32-bit
  and 64-bit operating systems
What is PHP
• Similar Syntax as C or Perl
• PHP stands for PHP: Hypertext Preprocessor
• PHP files have a file extension of ".php", ".php3",
  or ".phtml"
• PHP is a server-side scripting language, like ASP
• PHP 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
Why PHP
•   PHP runs on different platforms (Windows,
 Linux, Unix, etc.)
• PHP is compatible with almost all servers used
 today (Apache, IIS, etc.)
• PHP is FREE to download from the official PHP
 resource: www.php.net
• PHP is easy to learn and runs efficiently on the
 server side
The Stack
• Apache (lighttpd, IIS)
• MySQL (PostgresSQL, SQL Server,
  Oracle)
• PHP
• PHPMyAdmin for adminisering your
  SQL Database
• Linux (BSD, Mac OS, Windows,
  Solaris)
The Stack
Syntax
<?php
echo "Hello World";
?>
PHP Variables
<?php
$txt="Hello World!";
$x=16;
?>
PHP Variable Types

    Local

    Global

    Static

    Parameter
PHP Global Variable
$a = 5; $b = 10;
function myTest()
{
global $a, $b;
$b = $a + $b;
}
myTest();
echo $b;
PHP Local Variable
$a = 5; // global scope
function myTest()
{
echo $a; // local scope
}
myTest();
PHP Static & Parameters
static $rememberMe;
function
  myTest($para1,$para2)
{
}
Operators
x + y Addition       Sum of x and y        2+2 4
x-y      Subtraction Difference of x and y       5-2     3
x * y Multiplication        Product of x and y 5 * 2 10
x/y      Division    Quotient of x and y         15 / 5 3
x % y Modulus        Remainder of x divided by y         5%2
- x Negation Opposite of x         -2
a.b      Concatenation      Concatenate two strings "Hi" . "Ha"   HiHa
x && y         And   True if both x and y are true
x || y Or      True if either or both x and y are true
PHP Array
$cars=array("Saab","BMW","Toyota");
$ages = array("ass1"=>32, "associative2"=>30);
$cars[0]="Saab";
$cars[2]="BMW";
$cars[3]="Toyota";
echo $cars[0] . " and " . $cars[1];
If else Statement
if (condition)
 {
 code to be executed if condition is true;
 }
else
 {
 code to be executed if condition is false;
 }
Switch Statement
$x=1;
switch ($x)
{
case 1:
    echo "Test Number 1";
    break;
case 2:
    echo "Test Number 2";
    break;
default:
    echo "No test number between 1 and 2"; }
While Statement
$i=1;
while($i<=5)
 {
 echo "This number is " . $i . "<br />";
 $i++;
 }
For Loop
for ($i=1; $i<=5; $i++)
 {
 echo "The number is " . $i .
 "<br />";
 }
Foreach Loop
$x=array("one","two","three");
foreach ($x as $value)
 {
 echo $value . "<br />";
 }
Function
<?php
 function add($x,$y)
 {
 $total=$x+$y;
 return $total;
 }
 echo "1 + 16 = " . add(1,16);
 ?>
HTML Form
<form action="welcome.php"
 method="post">
 Name: <input type="text"
 name="fname" />
 Age: <input type="text" name="age" />
 <input type="submit" />
</form>
GET & POST
 Welcome <?php echo $_POST["fname"]; ?>
 You are <?php echo $_POST["age"]; ?> years old.
OR
http://example.com/test.php?fname=Peter&age=37
 Welcome <?php echo $_GET["fname"]; ?>.<br />
 You are <?php echo $_GET["age"]; ?> years old!
Mysql Connection
$con =
  mysql_connect("localhost","peter","abc123");
  if (!$con)
    {
    die('Could not connect: ' . mysql_error());
    }
  mysql_select_db("my_db", $con);
  mysql_close($con);
Mysql Query

 $sql="INSERT INTO Persons (FirstName, Age)
  VALUES
  ('$_POST[fname], '$_POST[age]')";
mysql_query($sql);


Select * FROM Persons
Update/Delete
Session & Cookie
session_start();
  if(isset($_SESSION['views']))
    unset($_SESSION['views]);

session_destroy();
setcookie(name,value,expire,domain,path,domain,secure,http
  only);
setcookie("TestCookie", $value, time()
  +3600, "/~rasmus/", "example.com", 1);
Thank you

Contact me @

http://www.linkedin.com/pub/mandakini-kumari/18/93/935
https://www.facebook.com/mandakini.kumari

More Related Content

What's hot (20)

PDF
Flask intro - ROSEdu web workshops
Alex Eftimie
 
PPTX
PHP Function
Reber Novanta
 
PDF
Os Pruett
oscon2007
 
KEY
Building a real life application in node js
fakedarren
 
PDF
Fluentd unified logging layer
Kiyoto Tamura
 
ODP
When dynamic becomes static : the next step in web caching techniques
Wim Godden
 
PDF
8 Minutes On Rack
danwrong
 
PDF
Slow Database in your PHP stack? Don't blame the DBA!
Harald Zeitlhofer
 
PPTX
MySQLi
Ankit Bahuguna
 
PDF
AJAX Transport Layer
Siarhei Barysiuk
 
PDF
Doing more with LESS
jsmith92
 
PDF
High Performance Ajax Applications
Siarhei Barysiuk
 
PDF
An Introduction to Tornado
Gavin Roy
 
PDF
4.4 PHP Session
Jalpesh Vasa
 
ODP
MongoDB & PHP
Sanjeev Shrestha
 
PDF
Website Performance Basics
geku
 
PPT
Develop webservice in PHP
Sanil Subhash Chandra Bose
 
PDF
Creating And Consuming Web Services In Php 5
Michael Girouard
 
PDF
Centralized + Unified Logging
Gabor Kozma
 
ODP
The promise of asynchronous PHP
Wim Godden
 
Flask intro - ROSEdu web workshops
Alex Eftimie
 
PHP Function
Reber Novanta
 
Os Pruett
oscon2007
 
Building a real life application in node js
fakedarren
 
Fluentd unified logging layer
Kiyoto Tamura
 
When dynamic becomes static : the next step in web caching techniques
Wim Godden
 
8 Minutes On Rack
danwrong
 
Slow Database in your PHP stack? Don't blame the DBA!
Harald Zeitlhofer
 
AJAX Transport Layer
Siarhei Barysiuk
 
Doing more with LESS
jsmith92
 
High Performance Ajax Applications
Siarhei Barysiuk
 
An Introduction to Tornado
Gavin Roy
 
4.4 PHP Session
Jalpesh Vasa
 
MongoDB & PHP
Sanjeev Shrestha
 
Website Performance Basics
geku
 
Develop webservice in PHP
Sanil Subhash Chandra Bose
 
Creating And Consuming Web Services In Php 5
Michael Girouard
 
Centralized + Unified Logging
Gabor Kozma
 
The promise of asynchronous PHP
Wim Godden
 

Viewers also liked (8)

PPT
Php Presentation
Manish Bothra
 
PPTX
PHP basic
Noveo
 
PPT
Html5 drupal7 with mandakini kumari(1)
Mandakini Kumari
 
PPTX
Drupal7 an introduction by ayushiinfotech
Mandakini Kumari
 
PDF
PHP Basic & Variables
M.Zalmai Rahmani
 
PPT
Chapter 02 php basic syntax
Dhani Ahmad
 
PPTX
Seminar: PHP Developer for Dummies
Achmad Solichin
 
DOCX
Best topics for seminar
shilpi nagpal
 
Php Presentation
Manish Bothra
 
PHP basic
Noveo
 
Html5 drupal7 with mandakini kumari(1)
Mandakini Kumari
 
Drupal7 an introduction by ayushiinfotech
Mandakini Kumari
 
PHP Basic & Variables
M.Zalmai Rahmani
 
Chapter 02 php basic syntax
Dhani Ahmad
 
Seminar: PHP Developer for Dummies
Achmad Solichin
 
Best topics for seminar
shilpi nagpal
 
Ad

Similar to Php basic for vit university (20)

PPT
php 1
tumetr1
 
PDF
WT_PHP_PART1.pdf
HambardeAtharva
 
PDF
Lecture14-Introduction to PHP-coding.pdf
IotenergyWater
 
PPT
PHP - Introduction to PHP Fundamentals
Vibrant Technologies & Computers
 
PDF
Introduction of PHP.pdf
karinaabyys
 
PPTX
Php mysql classes in navi-mumbai,php-mysql course provider-in-navi-mumbai,bes...
anshkhurana01
 
PPT
PHP
sometech
 
PPTX
Unit 5-PHP Declaring variables, data types, array, string, operators, Expres...
DRambabu3
 
PPTX
introduction to php and its uses in daily
vishal choudhary
 
PPTX
Introduction to PHP.pptx
SherinRappai
 
PPTX
Php training in chandigarh
CBitss Technologies
 
PPTX
Php basics
Jamshid Hashimi
 
PPTX
Php Unit 1
team11vgnt
 
PPTX
FYBSC IT Web Programming Unit IV PHP and MySQL
Arti Parab Academics
 
PDF
Phpbasics
PrinceGuru MS
 
PPT
PHP and MySQL
Sanketkumar Biswas
 
PPT
PHP and MySQL.ppt
ROGELIOVILLARUBIA
 
PPTX
virtual lab pratical.pptx iot sensor practical ppt
a65617949
 
PPTX
PHP Hypertext Preprocessor
adeel990
 
PPT
10_introduction_php.ppt
GiyaShefin
 
php 1
tumetr1
 
WT_PHP_PART1.pdf
HambardeAtharva
 
Lecture14-Introduction to PHP-coding.pdf
IotenergyWater
 
PHP - Introduction to PHP Fundamentals
Vibrant Technologies & Computers
 
Introduction of PHP.pdf
karinaabyys
 
Php mysql classes in navi-mumbai,php-mysql course provider-in-navi-mumbai,bes...
anshkhurana01
 
Unit 5-PHP Declaring variables, data types, array, string, operators, Expres...
DRambabu3
 
introduction to php and its uses in daily
vishal choudhary
 
Introduction to PHP.pptx
SherinRappai
 
Php training in chandigarh
CBitss Technologies
 
Php basics
Jamshid Hashimi
 
Php Unit 1
team11vgnt
 
FYBSC IT Web Programming Unit IV PHP and MySQL
Arti Parab Academics
 
Phpbasics
PrinceGuru MS
 
PHP and MySQL
Sanketkumar Biswas
 
PHP and MySQL.ppt
ROGELIOVILLARUBIA
 
virtual lab pratical.pptx iot sensor practical ppt
a65617949
 
PHP Hypertext Preprocessor
adeel990
 
10_introduction_php.ppt
GiyaShefin
 
Ad

More from Mandakini Kumari (8)

PPTX
Emerging Trends In Cloud Computing.pptx
Mandakini Kumari
 
PPTX
Building an Edge Computing Strategy - Distributed infrastructure.pptx
Mandakini Kumari
 
PPTX
Emerging Trends in Cloud Computing.pptx
Mandakini Kumari
 
PPTX
Women in IT & Inspirational Individual of the Year.pptx
Mandakini Kumari
 
PPT
Big data with hadoop Setup on Ubuntu 12.04
Mandakini Kumari
 
PPTX
Web services soap and rest by mandakini for TechGig
Mandakini Kumari
 
PPT
Introduction of drupal7 by ayushi infotech
Mandakini Kumari
 
PPT
Drupal 7 theme by ayushi infotech
Mandakini Kumari
 
Emerging Trends In Cloud Computing.pptx
Mandakini Kumari
 
Building an Edge Computing Strategy - Distributed infrastructure.pptx
Mandakini Kumari
 
Emerging Trends in Cloud Computing.pptx
Mandakini Kumari
 
Women in IT & Inspirational Individual of the Year.pptx
Mandakini Kumari
 
Big data with hadoop Setup on Ubuntu 12.04
Mandakini Kumari
 
Web services soap and rest by mandakini for TechGig
Mandakini Kumari
 
Introduction of drupal7 by ayushi infotech
Mandakini Kumari
 
Drupal 7 theme by ayushi infotech
Mandakini Kumari
 

Recently uploaded (20)

PDF
Generative AI: it's STILL not a robot (CIJ Summer 2025)
Paul Bradshaw
 
PPTX
HUMAN RESOURCE MANAGEMENT: RECRUITMENT, SELECTION, PLACEMENT, DEPLOYMENT, TRA...
PRADEEP ABOTHU
 
PPTX
How to Set Up Tags in Odoo 18 - Odoo Slides
Celine George
 
PDF
0725.WHITEPAPER-UNIQUEWAYSOFPROTOTYPINGANDUXNOW.pdf
Thomas GIRARD, MA, CDP
 
PDF
Reconstruct, Restore, Reimagine: New Perspectives on Stoke Newington’s Histor...
History of Stoke Newington
 
PPTX
Post Dated Cheque(PDC) Management in Odoo 18
Celine George
 
PDF
CONCURSO DE POESIA “POETUFAS – PASSOS SUAVES PELO VERSO.pdf
Colégio Santa Teresinha
 
PDF
The Different Types of Non-Experimental Research
Thelma Villaflores
 
PPTX
I AM MALALA The Girl Who Stood Up for Education and was Shot by the Taliban...
Beena E S
 
PPTX
Stereochemistry-Optical Isomerism in organic compoundsptx
Tarannum Nadaf-Mansuri
 
PPTX
ASRB NET 2023 PREVIOUS YEAR QUESTION PAPER GENETICS AND PLANT BREEDING BY SAT...
Krashi Coaching
 
PPT
Talk on Critical Theory, Part One, Philosophy of Social Sciences
Soraj Hongladarom
 
PDF
Dimensions of Societal Planning in Commonism
StefanMz
 
PPTX
GRADE-3-PPT-EVE-2025-ENG-Q1-LESSON-1.pptx
EveOdrapngimapNarido
 
PPTX
PPT-Q1-WK-3-ENGLISH Revised Matatag Grade 3.pptx
reijhongidayawan02
 
PDF
ARAL_Orientation_Day-2-Sessions_ARAL-Readung ARAL-Mathematics ARAL-Sciencev2.pdf
JoelVilloso1
 
PPTX
How to Handle Salesperson Commision in Odoo 18 Sales
Celine George
 
PDF
Exploring the Different Types of Experimental Research
Thelma Villaflores
 
PPTX
Universal immunization Programme (UIP).pptx
Vishal Chanalia
 
PPTX
How to Create Odoo JS Dialog_Popup in Odoo 18
Celine George
 
Generative AI: it's STILL not a robot (CIJ Summer 2025)
Paul Bradshaw
 
HUMAN RESOURCE MANAGEMENT: RECRUITMENT, SELECTION, PLACEMENT, DEPLOYMENT, TRA...
PRADEEP ABOTHU
 
How to Set Up Tags in Odoo 18 - Odoo Slides
Celine George
 
0725.WHITEPAPER-UNIQUEWAYSOFPROTOTYPINGANDUXNOW.pdf
Thomas GIRARD, MA, CDP
 
Reconstruct, Restore, Reimagine: New Perspectives on Stoke Newington’s Histor...
History of Stoke Newington
 
Post Dated Cheque(PDC) Management in Odoo 18
Celine George
 
CONCURSO DE POESIA “POETUFAS – PASSOS SUAVES PELO VERSO.pdf
Colégio Santa Teresinha
 
The Different Types of Non-Experimental Research
Thelma Villaflores
 
I AM MALALA The Girl Who Stood Up for Education and was Shot by the Taliban...
Beena E S
 
Stereochemistry-Optical Isomerism in organic compoundsptx
Tarannum Nadaf-Mansuri
 
ASRB NET 2023 PREVIOUS YEAR QUESTION PAPER GENETICS AND PLANT BREEDING BY SAT...
Krashi Coaching
 
Talk on Critical Theory, Part One, Philosophy of Social Sciences
Soraj Hongladarom
 
Dimensions of Societal Planning in Commonism
StefanMz
 
GRADE-3-PPT-EVE-2025-ENG-Q1-LESSON-1.pptx
EveOdrapngimapNarido
 
PPT-Q1-WK-3-ENGLISH Revised Matatag Grade 3.pptx
reijhongidayawan02
 
ARAL_Orientation_Day-2-Sessions_ARAL-Readung ARAL-Mathematics ARAL-Sciencev2.pdf
JoelVilloso1
 
How to Handle Salesperson Commision in Odoo 18 Sales
Celine George
 
Exploring the Different Types of Experimental Research
Thelma Villaflores
 
Universal immunization Programme (UIP).pptx
Vishal Chanalia
 
How to Create Odoo JS Dialog_Popup in Odoo 18
Celine George
 

Php basic for vit university

  • 1. PHP Basic Mandakini Kumari 22 July 2012 nd http://www.slideshare.net/mandakinikumari Mandakini Ayushi Infotech
  • 2. Overview A Brief History What is PHP Why PHP PHP Stack PHP Syntax Variables PHP String PHP Operators
  • 3. Overview PHP Arrays PHP If...Else PHP Switch PHP While For Loop Foreach Function Form,Get,Post
  • 5. A brief history • Created by Rasmus Lerdorf in 1995 • PHP: Hypertext Preprocessor • PHP interpreters available on 32-bit and 64-bit operating systems
  • 6. What is PHP • Similar Syntax as C or Perl • PHP stands for PHP: Hypertext Preprocessor • PHP files have a file extension of ".php", ".php3", or ".phtml" • PHP is a server-side scripting language, like ASP • PHP 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
  • 7. Why PHP • PHP runs on different platforms (Windows, Linux, Unix, etc.) • PHP is compatible with almost all servers used today (Apache, IIS, etc.) • PHP is FREE to download from the official PHP resource: www.php.net • PHP is easy to learn and runs efficiently on the server side
  • 8. The Stack • Apache (lighttpd, IIS) • MySQL (PostgresSQL, SQL Server, Oracle) • PHP • PHPMyAdmin for adminisering your SQL Database • Linux (BSD, Mac OS, Windows, Solaris)
  • 12. PHP Variable Types  Local  Global  Static  Parameter
  • 13. PHP Global Variable $a = 5; $b = 10; function myTest() { global $a, $b; $b = $a + $b; } myTest(); echo $b;
  • 14. PHP Local Variable $a = 5; // global scope function myTest() { echo $a; // local scope } myTest();
  • 15. PHP Static & Parameters static $rememberMe; function myTest($para1,$para2) { }
  • 16. Operators x + y Addition Sum of x and y 2+2 4 x-y Subtraction Difference of x and y 5-2 3 x * y Multiplication Product of x and y 5 * 2 10 x/y Division Quotient of x and y 15 / 5 3 x % y Modulus Remainder of x divided by y 5%2 - x Negation Opposite of x -2 a.b Concatenation Concatenate two strings "Hi" . "Ha" HiHa x && y And True if both x and y are true x || y Or True if either or both x and y are true
  • 17. PHP Array $cars=array("Saab","BMW","Toyota"); $ages = array("ass1"=>32, "associative2"=>30); $cars[0]="Saab"; $cars[2]="BMW"; $cars[3]="Toyota"; echo $cars[0] . " and " . $cars[1];
  • 18. If else Statement if (condition) { code to be executed if condition is true; } else { code to be executed if condition is false; }
  • 19. Switch Statement $x=1; switch ($x) { case 1: echo "Test Number 1"; break; case 2: echo "Test Number 2"; break; default: echo "No test number between 1 and 2"; }
  • 20. While Statement $i=1; while($i<=5) { echo "This number is " . $i . "<br />"; $i++; }
  • 21. For Loop for ($i=1; $i<=5; $i++) { echo "The number is " . $i . "<br />"; }
  • 22. Foreach Loop $x=array("one","two","three"); foreach ($x as $value) { echo $value . "<br />"; }
  • 23. Function <?php function add($x,$y) { $total=$x+$y; return $total; } echo "1 + 16 = " . add(1,16); ?>
  • 24. HTML Form <form action="welcome.php" method="post"> Name: <input type="text" name="fname" /> Age: <input type="text" name="age" /> <input type="submit" /> </form>
  • 25. GET & POST Welcome <?php echo $_POST["fname"]; ?> You are <?php echo $_POST["age"]; ?> years old. OR http://example.com/test.php?fname=Peter&age=37 Welcome <?php echo $_GET["fname"]; ?>.<br /> You are <?php echo $_GET["age"]; ?> years old!
  • 26. Mysql Connection $con = mysql_connect("localhost","peter","abc123"); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("my_db", $con); mysql_close($con);
  • 27. Mysql Query $sql="INSERT INTO Persons (FirstName, Age) VALUES ('$_POST[fname], '$_POST[age]')"; mysql_query($sql); Select * FROM Persons Update/Delete
  • 28. Session & Cookie session_start(); if(isset($_SESSION['views'])) unset($_SESSION['views]); session_destroy(); setcookie(name,value,expire,domain,path,domain,secure,http only); setcookie("TestCookie", $value, time() +3600, "/~rasmus/", "example.com", 1);
  • 29. Thank you Contact me @ http://www.linkedin.com/pub/mandakini-kumari/18/93/935 https://www.facebook.com/mandakini.kumari