SlideShare a Scribd company logo
1 of 31
Introduction To PHPIntroduction To PHP
ContentsContents
• IntroductionIntroduction
• Environmental SetupEnvironmental Setup
• Syntax OverviewSyntax Overview
• Variable typesVariable types
• OperatorsOperators
• Decision makingDecision making
• Looping statementsLooping statements
• ArraysArrays
• StringsStrings
• Get and postGet and post
• Database (MYSQL)Database (MYSQL)
IntroductionIntroduction
The PHP Hypertext Preprocessor (PHP) is a programming language that
allows web developers to create dynamic content that interacts with
databases. PHP is basically used for developing web based software
applications.
<html>
<head>
<title>PHP Script Execution</title>
</head>
<body>
<?php echo "<h1>Hello, PHP!</h1>";
?>
</body>
</html>
Environmental SetupEnvironmental Setup
• Web Server (WAMP)
• Database (MYSQL)
• PHP Editor (Dreamviewer ,sublime, notepad++)
Syntax OverviewSyntax Overview
•Canonical PHP tagsCanonical PHP tags
<?php...
?>
• Commenting PHP CodeCommenting PHP Code
Single-line comments − They are generally used for short explanations or notes
relevant to the local code. Here are the examples of single line comments.
<?
// This is a comment too. Each style comments only
print "An example with single line comments"; ?>
•Multi-lines commentsMulti-lines comments
<? /* This is a comment with multiline Author : Mohammad Mohtashim Purpose:
Multiline Comments Demo Subject: PHP */
print "An example with multi line comments"; ?>
PHP is case sensitivePHP is case sensitive
<html>
<body>
<?php
$capital = 67;
print("Variable capital is $capital<br>");
print("Variable CaPiTaL is $CaPiTaL<br>");
?>
</body>
</html>
Variable typesVariable types
• All variables in PHP are denoted with a leading dollar sign ($).
• PHP variables are Perl-like,C Language .
 Integers − are whole numbers, without a decimal point, like 4195.
 Doubles − are floating-point numbers, like 3.14159 or 49.1.
 Booleans − have only two possible values either true or false.
 NULL − is a special type that only has one value: NULL.
 Strings − are sequences of characters, like 'PHP supports string
operations.‘
 Arrays − are named and indexed collections of other values.
ExampleExample
• $int_var = 12345;
• $another_int = -12345 + 12345;
<?php
$many = 2.2888800;
$many_2 = 2.2111200;
$few = $many + $many_2;
print("$many + $many_2 = $few <br>");
?>
OperatorsOperators
• Arithmetic OperatorsArithmetic Operators
• Assignment OperatorsAssignment Operators
• Comparison OperatorsComparison Operators
• Logical (or Relational) OperatorsLogical (or Relational) Operators
ExamplesExamples
Arithmetic OperatorsArithmetic Operators
<!DOCTYPE html>
<html>
<body>
<?php
$x = 10;
$y = 6;
echo $x + $y;
?>
</body>
</html>
Assignment OperatorsAssignment Operators
<!DOCTYPE html>
<html>
<body>
<?php
$x = 50;
$x -= 30;
echo $x;
?>
</body>
</html>
Comparison OperatorsComparison Operators
<!DOCTYPE html>
<html>
<body>
<?php
$x = 50;
$y = 50;
var_dump($x >= $y);
?>
</body>
</html>
Logical (or Relational) OperatorsLogical (or Relational) Operators
ExampleExample
<!DOCTYPE html>
<html>
<body>
<?php
$x = 100;
$y = 50;
if ($x == 100 && $y == 50) {
echo "Hello world!";
}
?>
</body>
</html>
Decision makingDecision making
IF Statements(Syntax)IF Statements(Syntax)
<html>
<body>
<?php
$d = date("D");
if ($d == "Fri")
echo "Have a nice weekend!";
else
echo "Have a nice day!"; ?>
</body>
</html>
ElseIf StatementElseIf Statement
<html>
<body>
<?php
$d = date("D");
if ($d == "Fri")
echo "Have a nice weekend!";
else if ($d == "Sun")
echo "Have a nice Sunday!";
else echo "Have a nice day!"; ?>
</body>
</html>
The Switch StatementThe Switch Statement
Looping statementsLooping statements
The for loop statementThe for loop statement
<?php
$a = 0; $b = 0;
for( $i = 0; $i<5; $i++ )
{
$a += 10; $b += 5;
}
echo ("At the end of the loop a = $a and b = $b" );
?>
The while loop statementThe while loop statement
<?php
$i = 0;
$num = 50;
while( $i < 10)
{
$num--;
$i++;
}
echo ("Loop stopped at i = $i and num = $num" );
?>
The do...while loop statementThe do...while loop statement
<?php
$i = 0;
$num = 0;
do
{
$i++;
} while( $i < 10 );
echo ("Loop stopped at i = $i" );
?>
The break statementThe break statement
Example
<?php
$i = 0;
while( $i < 10)
{
$i++;
if( $i == 3 )break;
}
echo ("Loop stopped at i = $i" );
?>
ArraysArrays
An array is a data structure that stores one or more similar type of values
in a single value
•Numeric array − An array with a numeric index. Values are stored and
accessed in linear fashion.
•Associative array − An array with strings as index. This stores element
values in association with key values rather than in
•Multidimensional array − An array containing one or more arrays and
values are accessed using multiple indices a strict linear index order.
ExampleExample
StringsStrings
String Concatenation OperatorString Concatenation Operator
<?php
$string1="Hello World";
$string2="1234";
echo $string1 . " " . $string2;
?>
Using the strlen() functionUsing the strlen() function
<?php echo strlen("Hello world!"); ?>
Get and postGet and post
GET METHODGET METHOD
The GET method sends the encoded user information appended to the
page request. The page and the encoded information are separated by
the ?character.
•Never use GET method if you have password or other sensitive
information to be sent to the server.
•GET can't be used to send binary data, like images or word documents, to
the server.
•The GET method is restricted to send upto 1024 characters only.
<?php
if( $_GET["name"] || $_GET["age"] ) {
echo "Welcome ". $_GET['name']. "<br />";
echo "You are ". $_GET['age']. " years old.";
exit();
}
?>
<html>
<body>
<form action = "<?php $_PHP_SELF ?>" method = "GET">
Name: <input type = "text" name = "name" />
Age: <input type = "text" name = "age" />
<input type = "submit" />
</form>
</body>
</html>
The POST MethodThe POST Method
•The POST method does not have any restriction on data size to be sent.
•The POST method can be used to send ASCII as well as binary data.
•The data sent by POST method goes through HTTP header so security
depends on HTTP protocol. By using Secure HTTP you can make sure that
your information is secure.
Database (MYSQL)
• DDL
• DML
• Queries
• Assignments on DDL and DML
• Wamp server installation
THANK YOUTHANK YOU

More Related Content

What's hot

What's hot (20)

Php
PhpPhp
Php
 
Class 3 - PHP Functions
Class 3 - PHP FunctionsClass 3 - PHP Functions
Class 3 - PHP Functions
 
Introduction to php
Introduction to phpIntroduction to php
Introduction to php
 
Introduction to PHP
Introduction to PHPIntroduction to PHP
Introduction to PHP
 
PHP slides
PHP slidesPHP slides
PHP slides
 
Control Structures In Php 2
Control Structures In Php 2Control Structures In Php 2
Control Structures In Php 2
 
Php Presentation
Php PresentationPhp Presentation
Php Presentation
 
Php basics
Php basicsPhp basics
Php basics
 
PHP FUNCTIONS
PHP FUNCTIONSPHP FUNCTIONS
PHP FUNCTIONS
 
GET and POST in PHP
GET and POST in PHPGET and POST in PHP
GET and POST in PHP
 
Php with MYSQL Database
Php with MYSQL DatabasePhp with MYSQL Database
Php with MYSQL Database
 
php
phpphp
php
 
4.2 PHP Function
4.2 PHP Function4.2 PHP Function
4.2 PHP Function
 
MVC in PHP
MVC in PHPMVC in PHP
MVC in PHP
 
Lesson 2 php data types
Lesson 2   php data typesLesson 2   php data types
Lesson 2 php data types
 
PHP POWERPOINT SLIDES
PHP POWERPOINT SLIDESPHP POWERPOINT SLIDES
PHP POWERPOINT SLIDES
 
Introduction to PHP
Introduction to PHPIntroduction to PHP
Introduction to PHP
 
PHP
PHPPHP
PHP
 
What Is Php
What Is PhpWhat Is Php
What Is Php
 
PHP variables
PHP  variablesPHP  variables
PHP variables
 

Viewers also liked

Beginners PHP Tutorial
Beginners PHP TutorialBeginners PHP Tutorial
Beginners PHP Tutorial
alexjones89
 

Viewers also liked (20)

Introduction to PHP
Introduction to PHPIntroduction to PHP
Introduction to PHP
 
Php Ppt
Php PptPhp Ppt
Php Ppt
 
Introduction to PHP
Introduction to PHPIntroduction to PHP
Introduction to PHP
 
Ch1(introduction to php)
Ch1(introduction to php)Ch1(introduction to php)
Ch1(introduction to php)
 
PHP - Introduction to PHP
PHP -  Introduction to PHPPHP -  Introduction to PHP
PHP - Introduction to PHP
 
Beginners PHP Tutorial
Beginners PHP TutorialBeginners PHP Tutorial
Beginners PHP Tutorial
 
PHP Summer Training Presentation
PHP Summer Training PresentationPHP Summer Training Presentation
PHP Summer Training Presentation
 
Introduction to php basics
Introduction to php   basicsIntroduction to php   basics
Introduction to php basics
 
Open Source Package PHP & MySQL
Open Source Package PHP & MySQLOpen Source Package PHP & MySQL
Open Source Package PHP & MySQL
 
Oops in PHP
Oops in PHPOops in PHP
Oops in PHP
 
PHP Powerpoint -- Teach PHP with this
PHP Powerpoint -- Teach PHP with thisPHP Powerpoint -- Teach PHP with this
PHP Powerpoint -- Teach PHP with this
 
Php mysql ppt
Php mysql pptPhp mysql ppt
Php mysql ppt
 
VT17 - DA287A - Kursintroduktion
VT17 - DA287A - KursintroduktionVT17 - DA287A - Kursintroduktion
VT17 - DA287A - Kursintroduktion
 
Php i-slides
Php i-slidesPhp i-slides
Php i-slides
 
learning html
learning htmllearning html
learning html
 
cake phptutorial
cake phptutorialcake phptutorial
cake phptutorial
 
Php a dynamic web scripting language
Php   a dynamic web scripting languagePhp   a dynamic web scripting language
Php a dynamic web scripting language
 
Basics PHP
Basics PHPBasics PHP
Basics PHP
 
Server Side Programming
Server Side Programming Server Side Programming
Server Side Programming
 
Client & server side scripting
Client & server side scriptingClient & server side scripting
Client & server side scripting
 

Similar to Introduction To PHP

Php i basic chapter 3 (syahir chaer's conflicted copy 2013-04-22)
Php i basic chapter 3 (syahir chaer's conflicted copy 2013-04-22)Php i basic chapter 3 (syahir chaer's conflicted copy 2013-04-22)
Php i basic chapter 3 (syahir chaer's conflicted copy 2013-04-22)
Muhamad Al Imran
 
Php i basic chapter 3 (afifah rosli's conflicted copy 2013-04-23)
Php i basic chapter 3 (afifah rosli's conflicted copy 2013-04-23)Php i basic chapter 3 (afifah rosli's conflicted copy 2013-04-23)
Php i basic chapter 3 (afifah rosli's conflicted copy 2013-04-23)
Muhamad Al Imran
 
Php introduction with history of php
Php introduction with history of phpPhp introduction with history of php
Php introduction with history of php
pooja bhandari
 

Similar to Introduction To PHP (20)

Php i basic chapter 3
Php i basic chapter 3Php i basic chapter 3
Php i basic chapter 3
 
Php i basic chapter 3 (syahir chaer's conflicted copy 2013-04-22)
Php i basic chapter 3 (syahir chaer's conflicted copy 2013-04-22)Php i basic chapter 3 (syahir chaer's conflicted copy 2013-04-22)
Php i basic chapter 3 (syahir chaer's conflicted copy 2013-04-22)
 
Php i basic chapter 3 (afifah rosli's conflicted copy 2013-04-23)
Php i basic chapter 3 (afifah rosli's conflicted copy 2013-04-23)Php i basic chapter 3 (afifah rosli's conflicted copy 2013-04-23)
Php i basic chapter 3 (afifah rosli's conflicted copy 2013-04-23)
 
WEB-MODULE 4.pdf
WEB-MODULE 4.pdfWEB-MODULE 4.pdf
WEB-MODULE 4.pdf
 
PHP complete reference with database concepts for beginners
PHP complete reference with database concepts for beginnersPHP complete reference with database concepts for beginners
PHP complete reference with database concepts for beginners
 
Hsc IT 5. Server-Side Scripting (PHP).pdf
Hsc IT 5. Server-Side Scripting (PHP).pdfHsc IT 5. Server-Side Scripting (PHP).pdf
Hsc IT 5. Server-Side Scripting (PHP).pdf
 
php 1
php 1php 1
php 1
 
Php Basics
Php BasicsPhp Basics
Php Basics
 
Php reports sumit
Php reports sumitPhp reports sumit
Php reports sumit
 
PHP Arrays - indexed and associative array.
PHP Arrays - indexed and associative array. PHP Arrays - indexed and associative array.
PHP Arrays - indexed and associative array.
 
05php
05php05php
05php
 
Php mysql classes in navi-mumbai,php-mysql course provider-in-navi-mumbai,bes...
Php mysql classes in navi-mumbai,php-mysql course provider-in-navi-mumbai,bes...Php mysql classes in navi-mumbai,php-mysql course provider-in-navi-mumbai,bes...
Php mysql classes in navi-mumbai,php-mysql course provider-in-navi-mumbai,bes...
 
LAB PHP Consolidated.ppt
LAB PHP Consolidated.pptLAB PHP Consolidated.ppt
LAB PHP Consolidated.ppt
 
php fundamental
php fundamentalphp fundamental
php fundamental
 
Php introduction with history of php
Php introduction with history of phpPhp introduction with history of php
Php introduction with history of php
 
php
phpphp
php
 
Php training100%placement-in-mumbai
Php training100%placement-in-mumbaiPhp training100%placement-in-mumbai
Php training100%placement-in-mumbai
 
PHP MySQL Workshop - facehook
PHP MySQL Workshop - facehookPHP MySQL Workshop - facehook
PHP MySQL Workshop - facehook
 
Practical catalyst
Practical catalystPractical catalyst
Practical catalyst
 
Php
PhpPhp
Php
 

Recently uploaded

Beyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactBeyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global Impact
PECB
 
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in DelhiRussian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
kauryashika82
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptx
heathfieldcps1
 
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
fonyou31
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
SoniaTolstoy
 

Recently uploaded (20)

Z Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphZ Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot Graph
 
fourth grading exam for kindergarten in writing
fourth grading exam for kindergarten in writingfourth grading exam for kindergarten in writing
fourth grading exam for kindergarten in writing
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy Consulting
 
Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104
 
Beyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactBeyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global Impact
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
 
Disha NEET Physics Guide for classes 11 and 12.pdf
Disha NEET Physics Guide for classes 11 and 12.pdfDisha NEET Physics Guide for classes 11 and 12.pdf
Disha NEET Physics Guide for classes 11 and 12.pdf
 
Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdf
 
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
 
APM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAPM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across Sectors
 
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in DelhiRussian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptx
 
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
 
Student login on Anyboli platform.helpin
Student login on Anyboli platform.helpinStudent login on Anyboli platform.helpin
Student login on Anyboli platform.helpin
 
9548086042 for call girls in Indira Nagar with room service
9548086042  for call girls in Indira Nagar  with room service9548086042  for call girls in Indira Nagar  with room service
9548086042 for call girls in Indira Nagar with room service
 
Unit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxUnit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptx
 
The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13
 
Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfKey note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdf
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
 
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
 

Introduction To PHP

  • 2. ContentsContents • IntroductionIntroduction • Environmental SetupEnvironmental Setup • Syntax OverviewSyntax Overview • Variable typesVariable types • OperatorsOperators • Decision makingDecision making • Looping statementsLooping statements • ArraysArrays • StringsStrings • Get and postGet and post • Database (MYSQL)Database (MYSQL)
  • 3. IntroductionIntroduction The PHP Hypertext Preprocessor (PHP) is a programming language that allows web developers to create dynamic content that interacts with databases. PHP is basically used for developing web based software applications. <html> <head> <title>PHP Script Execution</title> </head> <body> <?php echo "<h1>Hello, PHP!</h1>"; ?> </body> </html>
  • 4. Environmental SetupEnvironmental Setup • Web Server (WAMP) • Database (MYSQL) • PHP Editor (Dreamviewer ,sublime, notepad++)
  • 5. Syntax OverviewSyntax Overview •Canonical PHP tagsCanonical PHP tags <?php... ?> • Commenting PHP CodeCommenting PHP Code Single-line comments − They are generally used for short explanations or notes relevant to the local code. Here are the examples of single line comments. <? // This is a comment too. Each style comments only print "An example with single line comments"; ?> •Multi-lines commentsMulti-lines comments <? /* This is a comment with multiline Author : Mohammad Mohtashim Purpose: Multiline Comments Demo Subject: PHP */ print "An example with multi line comments"; ?>
  • 6. PHP is case sensitivePHP is case sensitive <html> <body> <?php $capital = 67; print("Variable capital is $capital<br>"); print("Variable CaPiTaL is $CaPiTaL<br>"); ?> </body> </html>
  • 7. Variable typesVariable types • All variables in PHP are denoted with a leading dollar sign ($). • PHP variables are Perl-like,C Language .  Integers − are whole numbers, without a decimal point, like 4195.  Doubles − are floating-point numbers, like 3.14159 or 49.1.  Booleans − have only two possible values either true or false.  NULL − is a special type that only has one value: NULL.  Strings − are sequences of characters, like 'PHP supports string operations.‘  Arrays − are named and indexed collections of other values.
  • 8. ExampleExample • $int_var = 12345; • $another_int = -12345 + 12345; <?php $many = 2.2888800; $many_2 = 2.2111200; $few = $many + $many_2; print("$many + $many_2 = $few <br>"); ?>
  • 9. OperatorsOperators • Arithmetic OperatorsArithmetic Operators • Assignment OperatorsAssignment Operators • Comparison OperatorsComparison Operators • Logical (or Relational) OperatorsLogical (or Relational) Operators
  • 10. ExamplesExamples Arithmetic OperatorsArithmetic Operators <!DOCTYPE html> <html> <body> <?php $x = 10; $y = 6; echo $x + $y; ?> </body> </html>
  • 11. Assignment OperatorsAssignment Operators <!DOCTYPE html> <html> <body> <?php $x = 50; $x -= 30; echo $x; ?> </body> </html>
  • 13. <!DOCTYPE html> <html> <body> <?php $x = 50; $y = 50; var_dump($x >= $y); ?> </body> </html>
  • 14. Logical (or Relational) OperatorsLogical (or Relational) Operators
  • 15. ExampleExample <!DOCTYPE html> <html> <body> <?php $x = 100; $y = 50; if ($x == 100 && $y == 50) { echo "Hello world!"; } ?> </body> </html>
  • 16. Decision makingDecision making IF Statements(Syntax)IF Statements(Syntax) <html> <body> <?php $d = date("D"); if ($d == "Fri") echo "Have a nice weekend!"; else echo "Have a nice day!"; ?> </body> </html>
  • 17. ElseIf StatementElseIf Statement <html> <body> <?php $d = date("D"); if ($d == "Fri") echo "Have a nice weekend!"; else if ($d == "Sun") echo "Have a nice Sunday!"; else echo "Have a nice day!"; ?> </body> </html>
  • 18. The Switch StatementThe Switch Statement
  • 19. Looping statementsLooping statements The for loop statementThe for loop statement <?php $a = 0; $b = 0; for( $i = 0; $i<5; $i++ ) { $a += 10; $b += 5; } echo ("At the end of the loop a = $a and b = $b" ); ?>
  • 20. The while loop statementThe while loop statement <?php $i = 0; $num = 50; while( $i < 10) { $num--; $i++; } echo ("Loop stopped at i = $i and num = $num" ); ?>
  • 21. The do...while loop statementThe do...while loop statement <?php $i = 0; $num = 0; do { $i++; } while( $i < 10 ); echo ("Loop stopped at i = $i" ); ?>
  • 22. The break statementThe break statement
  • 23. Example <?php $i = 0; while( $i < 10) { $i++; if( $i == 3 )break; } echo ("Loop stopped at i = $i" ); ?>
  • 24. ArraysArrays An array is a data structure that stores one or more similar type of values in a single value •Numeric array − An array with a numeric index. Values are stored and accessed in linear fashion. •Associative array − An array with strings as index. This stores element values in association with key values rather than in •Multidimensional array − An array containing one or more arrays and values are accessed using multiple indices a strict linear index order.
  • 26. StringsStrings String Concatenation OperatorString Concatenation Operator <?php $string1="Hello World"; $string2="1234"; echo $string1 . " " . $string2; ?> Using the strlen() functionUsing the strlen() function <?php echo strlen("Hello world!"); ?>
  • 27. Get and postGet and post GET METHODGET METHOD The GET method sends the encoded user information appended to the page request. The page and the encoded information are separated by the ?character. •Never use GET method if you have password or other sensitive information to be sent to the server. •GET can't be used to send binary data, like images or word documents, to the server. •The GET method is restricted to send upto 1024 characters only.
  • 28. <?php if( $_GET["name"] || $_GET["age"] ) { echo "Welcome ". $_GET['name']. "<br />"; echo "You are ". $_GET['age']. " years old."; exit(); } ?> <html> <body> <form action = "<?php $_PHP_SELF ?>" method = "GET"> Name: <input type = "text" name = "name" /> Age: <input type = "text" name = "age" /> <input type = "submit" /> </form> </body> </html>
  • 29. The POST MethodThe POST Method •The POST method does not have any restriction on data size to be sent. •The POST method can be used to send ASCII as well as binary data. •The data sent by POST method goes through HTTP header so security depends on HTTP protocol. By using Secure HTTP you can make sure that your information is secure.
  • 30. Database (MYSQL) • DDL • DML • Queries • Assignments on DDL and DML • Wamp server installation