SlideShare una empresa de Scribd logo
1 de 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

Más contenido relacionado

La actualidad más candente

La actualidad más candente (20)

Basics of JavaScript
Basics of JavaScriptBasics of JavaScript
Basics of JavaScript
 
Php.ppt
Php.pptPhp.ppt
Php.ppt
 
JavaScript Programming
JavaScript ProgrammingJavaScript Programming
JavaScript Programming
 
Introduction to PHP - Basics of PHP
Introduction to PHP - Basics of PHPIntroduction to PHP - Basics of PHP
Introduction to PHP - Basics of PHP
 
Php Tutorial
Php TutorialPhp Tutorial
Php Tutorial
 
4.2 PHP Function
4.2 PHP Function4.2 PHP Function
4.2 PHP Function
 
Introduction to php
Introduction to phpIntroduction to php
Introduction to php
 
Javascript
JavascriptJavascript
Javascript
 
Control Structures In Php 2
Control Structures In Php 2Control Structures In Php 2
Control Structures In Php 2
 
PHP - Introduction to Object Oriented Programming with PHP
PHP -  Introduction to  Object Oriented Programming with PHPPHP -  Introduction to  Object Oriented Programming with PHP
PHP - Introduction to Object Oriented Programming with PHP
 
Lab #2: Introduction to Javascript
Lab #2: Introduction to JavascriptLab #2: Introduction to Javascript
Lab #2: Introduction to Javascript
 
Php
PhpPhp
Php
 
Introduction to PHP
Introduction to PHPIntroduction to PHP
Introduction to PHP
 
PHP - Introduction to File Handling with PHP
PHP -  Introduction to  File Handling with PHPPHP -  Introduction to  File Handling with PHP
PHP - Introduction to File Handling with PHP
 
Php and MySQL
Php and MySQLPhp and MySQL
Php and MySQL
 
JavaScript - Chapter 12 - Document Object Model
  JavaScript - Chapter 12 - Document Object Model  JavaScript - Chapter 12 - Document Object Model
JavaScript - Chapter 12 - Document Object Model
 
Class 3 - PHP Functions
Class 3 - PHP FunctionsClass 3 - PHP Functions
Class 3 - PHP Functions
 
Javascript basics
Javascript basicsJavascript basics
Javascript basics
 
Js ppt
Js pptJs ppt
Js ppt
 
Php Tutorials for Beginners
Php Tutorials for BeginnersPhp Tutorials for Beginners
Php Tutorials for Beginners
 

Destacado

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

Destacado (20)

Php Ppt
Php PptPhp Ppt
Php Ppt
 
Introduction to PHP
Introduction to PHPIntroduction to PHP
Introduction to PHP
 
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
 
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
 
How to make Android apps secure: dos and don’ts
How to make Android apps secure: dos and don’tsHow to make Android apps secure: dos and don’ts
How to make Android apps secure: dos and don’ts
 

Similar a 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 a 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 FUNCTIONS
PHP FUNCTIONSPHP FUNCTIONS
PHP FUNCTIONS
 
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
 

Último

Making and Justifying Mathematical Decisions.pdf
Making and Justifying Mathematical Decisions.pdfMaking and Justifying Mathematical Decisions.pdf
Making and Justifying Mathematical Decisions.pdf
Chris Hunter
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdf
QucHHunhnh
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdf
ciinovamais
 
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
 
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
 

Último (20)

Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17
 
Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104
 
PROCESS RECORDING FORMAT.docx
PROCESS      RECORDING        FORMAT.docxPROCESS      RECORDING        FORMAT.docx
PROCESS RECORDING FORMAT.docx
 
ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.
 
ICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptx
 
Micro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdfMicro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdf
 
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxBasic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
 
Making and Justifying Mathematical Decisions.pdf
Making and Justifying Mathematical Decisions.pdfMaking and Justifying Mathematical Decisions.pdf
Making and Justifying Mathematical Decisions.pdf
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdf
 
How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdf
 
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
 
General Principles of Intellectual Property: Concepts of Intellectual Proper...
General Principles of Intellectual Property: Concepts of Intellectual  Proper...General Principles of Intellectual Property: Concepts of Intellectual  Proper...
General Principles of Intellectual Property: Concepts of Intellectual Proper...
 
Unit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptxUnit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptx
 
Class 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdfClass 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdf
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and Mode
 
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
 
Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...
Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...
Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...
 
Asian American Pacific Islander Month DDSD 2024.pptx
Asian American Pacific Islander Month DDSD 2024.pptxAsian American Pacific Islander Month DDSD 2024.pptx
Asian American Pacific Islander Month DDSD 2024.pptx
 
psychiatric nursing HISTORY COLLECTION .docx
psychiatric  nursing HISTORY  COLLECTION  .docxpsychiatric  nursing HISTORY  COLLECTION  .docx
psychiatric nursing HISTORY COLLECTION .docx
 

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