SlideShare a Scribd company logo
PHP
MOHAMED LOEY
Agenda
 Part I: Introduction
 Part II: PHP Syntax
 Part III: PHP Form Handling
Agenda
 Part I: Introduction
 What is PHP?
 Why we use PHP?
 PHP Can
 Set Up PHP on Your Own PC
What is PHP?
 PHP is a server scripting language, and
is a powerful tool for making dynamic
and interactive Web pages quickly.
 PHP is a widely-used, open source
scripting language
 PHP scripts are executed on the server
 PHP costs nothing, it is free to
download and use
Why we use PHP?
 PHP runs on various platforms (Windows, Linux,
Unix, Mac OS X, etc.)
 PHP is compatible with almost all servers used
today (Apache, IIS, etc.)
 PHP supports a wide range of databases
 PHP is easy to learn and runs efficiently on the
server side
 It is powerful enough to be at the core of the
biggest blogging system on the web
(WordPress)!
 It is deep enough to run the largest social
network (Facebook)!
PHP Can
 Generate dynamic page content
 Create, open, read, write, delete, and
close files on the server
 Send and receive cookies
 Add, delete, modify data in your
database
 Encrypt data
 Output images, PDF files, and even
Flash movies
Set Up PHP on Your Own PC
 Install a web server (Apache)
 Install PHP
 Install a database, such as MySQL
 Example: XAMPP (Apache + MySQL +
PHP + Perl)
 XAMPP is the most popular PHP
development environment
Agenda
 Part II: PHP Syntax
 PHP Syntax
 Comments in PHP
 PHP Case Sensitivity
 PHP Variables
 PHP echo and print Statements
 PHP Operators
 PHP Conditional Statements
 PHP Loops
 PHP Functions
 PHP Arrays
PHP Syntax
 PHP script can be placed anywhere in
the document.
 A PHP script starts with <?php and
ends with ?>
 The default file extension for PHP files
is ".php".
Simple PHP Code
Comments in PHP
 A comment in PHP code is a line that is
not read/executed as part of the
program.
 PHP supports three ways of
commenting:
PHP Case Sensitivity
 In PHP, all user-defined functions,
classes, and keywords (e.g. if, else,
while, echo, etc.) are NOT case-
sensitive.
 Example:
PHP Case Sensitivity
 However; in PHP, all variables are case-
sensitive.
 $color, $COLOR, and $coLOR are
treated as three different variables
 Example:
PHP Variables
 Variables are "containers" for storing
information.
 A variable starts with the $ sign, followed by
the name of the variable
 A variable name must start with a letter or
the underscore character
 A variable name cannot start with a number
 A variable name can only contain alpha-
numeric characters and underscores (A-z, 0-9,
and _ )
 Variable names are case sensitive ($y and $Y
are two different variables)
PHP Variables
 PHP has no command for declaring a variable.
 Example:
PHP echo and print Statements
 In PHP there are two basic ways to get output:
echo and print.
 There are some differences between echo and
print:
 echo - can output one or more strings
 print - can only output one string, and returns always
1
 Example:
PHP Operators
 PHP Arithmetic Operators
PHP Operators
 PHP Arithmetic Operators Example:
PHP Operators
 PHP Assignment Operators
PHP Operators
 PHP Assignment Operators Example:
PHP Operators
 PHP String Operators
PHP Operators
 PHP String Operators Example:
PHP Operators
 PHP Increment / Decrement Operators
PHP Operators
 PHP Increment / Decrement Operators
Example:
PHP Operators
 PHP Comparison Operators
PHP Operators
 PHP Comparison Operators Example:
PHP Operators
 PHP Logical Operators
PHP Operators
 PHP Array Operators
PHP Operators
 PHP Array Operators Example:
PHP Conditional Statements
 In PHP we have the following conditional
statements:
 if statement - executes some code only if a specified
condition is true
 if...else statement - executes some code if a
condition is true and another code if the condition is
false
 if...elseif....else statement - selects one of several
blocks of code to be executed
 switch statement - selects one of many blocks of
code to be executed
PHP Conditional Statements
 If else Example:
PHP Conditional Statements
 Switch example:
PHP Loops
 In PHP, we have the following looping
statements:
 while - loops through a block of code as long as the
specified condition is true
 do...while - loops through a block of code once, and
then repeats the loop as long as the specified
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
PHP Loops
 PHP while Loop example:
PHP Loops
 PHP do...while Loop example:
PHP Loops
 PHP for Loop example:
PHP Loops
 PHP foreach Loop example:
PHP Functions
 A function is a block of statements that can be
used repeatedly in a program.
 A function will not execute immediately when a
page loads.
 A function will be executed by a call to the
function.
PHP Functions
 PHP function examples:
PHP Arrays
 An array is a special variable, which can hold
more than one value at a time.
 Example:
PHP Associative Arrays
 Associative arrays are arrays that use named
keys that you assign to them.
 Example:
PHP Sorting Arrays
 PHP array sort functions:
 sort() - sort arrays in ascending order
 rsort() - sort arrays in descending order
 asort() - sort associative arrays in ascending order,
according to the value
 ksort() - sort associative arrays in ascending order,
according to the key
 arsort() - sort associative arrays in descending order,
according to the value
 krsort() - sort associative arrays in descending order,
according to the key
Agenda
 Part III: PHP Form Handling
 PHP GET vs. POST
 PHP $_GET
 PHP $_POST
PHP Form Handling
 One of the most powerful features of PHP is
the way it handles HTML forms. The basic
concept that is important to understand is
that any form element will automatically be
available to your PHP scripts.
 The PHP $_GET and $_POST are used to
collect form-data.
PHP GET vs. POST
 Both GET and POST create an array (e.g. array( key
=> value, key2 => value2, key3 => value3, ...)). This
array holds key/value pairs, where keys are the
names of the form controls and values are the input
data from the user.
 When to use GET?
 Information sent from a form with the GET method
is visible to everyone
 facebook.com?welcome.php?name=Mohamed
 When to use POST?
 Information sent from a form with the POST
method is invisible to others
 facebook.com?welcome.php
PHP $_GET
 Example:
PHP $_GET
 When the user fills out the form above and
clicks the submit button, the form data is sent
for processing to a PHP file named
"welcome.php".
 welcome.php
PHP $_GET
 Result:
 Welocome.php Output
PHP $_POST
 Example:
PHP $_POST
 When the user fills out the form above and
clicks the submit button, the form data is sent
for processing to a PHP file named
"welcome.php".
 welcome.php
PHP $_POST
 Result:
 Welocome.php Output
THANK U

More Related Content

What's hot (20)

PPTX
Welcome to computer programmer 2
MLG College of Learning, Inc
 
PPTX
Constructor and encapsulation in php
SHIVANI SONI
 
PDF
php_tizag_tutorial
tutorialsruby
 
PDF
Php introduction
krishnapriya Tadepalli
 
PDF
Introduction to php
Anjan Banda
 
PPT
Control Structures In Php 2
Digital Insights - Digital Marketing Agency
 
PPT
Chapter 02 php basic syntax
Dhani Ahmad
 
PDF
Php a dynamic web scripting language
Elmer Concepcion Jr.
 
PPT
Php mysql
Shehrevar Davierwala
 
PPT
Introduction to php
Meetendra Singh
 
PPTX
Php.ppt
Nidhi mishra
 
PDF
Introduction to php
KIRAN KUMAR SILIVERI
 
PPTX
php basics
Anmol Paul
 
PPTX
Php
Shyam Khant
 
PPT
Php(report)
Yhannah
 
PPTX
Dev traning 2016 basics of PHP
Sacheen Dhanjie
 
PDF
Php tutorial(w3schools)
Arjun Shanka
 
PPTX
PHP
Steve Fort
 
Welcome to computer programmer 2
MLG College of Learning, Inc
 
Constructor and encapsulation in php
SHIVANI SONI
 
php_tizag_tutorial
tutorialsruby
 
Php introduction
krishnapriya Tadepalli
 
Introduction to php
Anjan Banda
 
Control Structures In Php 2
Digital Insights - Digital Marketing Agency
 
Chapter 02 php basic syntax
Dhani Ahmad
 
Php a dynamic web scripting language
Elmer Concepcion Jr.
 
Introduction to php
Meetendra Singh
 
Php.ppt
Nidhi mishra
 
Introduction to php
KIRAN KUMAR SILIVERI
 
php basics
Anmol Paul
 
Php(report)
Yhannah
 
Dev traning 2016 basics of PHP
Sacheen Dhanjie
 
Php tutorial(w3schools)
Arjun Shanka
 

Viewers also liked (20)

PPT
MySql slides (ppt)
webhostingguy
 
PPT
Php Coding Convention
Phuong Vy
 
ODP
Coding In Php
Harit Kothari
 
PPTX
PHP FUNCTIONS
Zeeshan Ahmed
 
PDF
كيف تحمي خصوصيتك علي مواقع التواصل الاجتماعي فيسبوك
Mohamed Loey
 
PDF
Introduction to php web programming - sessions and cookies
baabtra.com - No. 1 supplier of quality freshers
 
ODP
Even internet computers want to be free: Using Linux and open source software...
North Bend Public Library
 
PPT
MySQL and its basic commands
Bwsrang Basumatary
 
ODP
Php variables (english)
Mahmoud Masih Tehrani
 
PPT
Php File Operations
mussawir20
 
PPTX
OOPS Characteristics (With Examples in PHP)
baabtra.com - No. 1 supplier of quality freshers
 
ODP
Htmltag.ppt
anandha ganesh
 
PDF
Computer Security Lecture 4: Block Ciphers and the Data Encryption Standard
Mohamed Loey
 
PDF
Arrays in PHP
Vineet Kumar Saini
 
PDF
Computer Security Lecture 3: Classical Encryption Techniques 2
Mohamed Loey
 
PPS
Execute MySQL query using command prompt
Ikhwan Krisnadi
 
PDF
What's new in PHP 7.1
Simon Jones
 
PPT
Php ppt
Sanmuga Nathan
 
ODP
Form Processing In Php
Harit Kothari
 
MySql slides (ppt)
webhostingguy
 
Php Coding Convention
Phuong Vy
 
Coding In Php
Harit Kothari
 
PHP FUNCTIONS
Zeeshan Ahmed
 
كيف تحمي خصوصيتك علي مواقع التواصل الاجتماعي فيسبوك
Mohamed Loey
 
Introduction to php web programming - sessions and cookies
baabtra.com - No. 1 supplier of quality freshers
 
Even internet computers want to be free: Using Linux and open source software...
North Bend Public Library
 
MySQL and its basic commands
Bwsrang Basumatary
 
Php variables (english)
Mahmoud Masih Tehrani
 
Php File Operations
mussawir20
 
OOPS Characteristics (With Examples in PHP)
baabtra.com - No. 1 supplier of quality freshers
 
Htmltag.ppt
anandha ganesh
 
Computer Security Lecture 4: Block Ciphers and the Data Encryption Standard
Mohamed Loey
 
Arrays in PHP
Vineet Kumar Saini
 
Computer Security Lecture 3: Classical Encryption Techniques 2
Mohamed Loey
 
Execute MySQL query using command prompt
Ikhwan Krisnadi
 
What's new in PHP 7.1
Simon Jones
 
Form Processing In Php
Harit Kothari
 
Ad

Similar to PHP Comprehensive Overview (20)

PPTX
introduction to php and its uses in daily
vishal choudhary
 
PPT
Intro to PHP for Students and professionals
cuyak
 
PPTX
Php training in chandigarh
CBitss Technologies
 
PPTX
php.pptx
nusky ahamed
 
PPT
PHP - Introduction to PHP Fundamentals
Vibrant Technologies & Computers
 
PPT
introduction to php web programming 2024.ppt
idaaryanie
 
PDF
basic concept of php(Gunikhan sonowal)
Guni Sonow
 
PPT
10_introduction_php.ppt
GiyaShefin
 
PPT
Php i-slides
zalatarunk
 
PPT
Php i-slides
Abu Bakar
 
PPT
Php i-slides (2) (1)
ravi18011991
 
PPT
Php i-slides
ravi18011991
 
PDF
Introduction of PHP.pdf
karinaabyys
 
PPT
PHP - Introduction to PHP - Mazenet Solution
Mazenetsolution
 
PPTX
Day1
IRWAA LLC
 
PPT
php41.ppt
Nishant804733
 
PPT
PHP InterLevel.ppt
NBACriteria2SICET
 
PPT
php-I-slides.ppt
SsewankamboErma
 
introduction to php and its uses in daily
vishal choudhary
 
Intro to PHP for Students and professionals
cuyak
 
Php training in chandigarh
CBitss Technologies
 
php.pptx
nusky ahamed
 
PHP - Introduction to PHP Fundamentals
Vibrant Technologies & Computers
 
introduction to php web programming 2024.ppt
idaaryanie
 
basic concept of php(Gunikhan sonowal)
Guni Sonow
 
10_introduction_php.ppt
GiyaShefin
 
Php i-slides
zalatarunk
 
Php i-slides
Abu Bakar
 
Php i-slides (2) (1)
ravi18011991
 
Php i-slides
ravi18011991
 
Introduction of PHP.pdf
karinaabyys
 
PHP - Introduction to PHP - Mazenet Solution
Mazenetsolution
 
Day1
IRWAA LLC
 
php41.ppt
Nishant804733
 
PHP InterLevel.ppt
NBACriteria2SICET
 
php-I-slides.ppt
SsewankamboErma
 
Ad

More from Mohamed Loey (20)

PDF
Lecture 6: Deep Learning Applications
Mohamed Loey
 
PDF
Lecture 5: Convolutional Neural Network Models
Mohamed Loey
 
PDF
Lecture 4: Deep Learning Frameworks
Mohamed Loey
 
PDF
Lecture 4: How it Works: Convolutional Neural Networks
Mohamed Loey
 
PPTX
Lecture 3: Convolutional Neural Networks
Mohamed Loey
 
PDF
Lecture 2: Artificial Neural Network
Mohamed Loey
 
PDF
Lecture 1: Deep Learning for Computer Vision
Mohamed Loey
 
PDF
Design of an Intelligent System for Improving Classification of Cancer Diseases
Mohamed Loey
 
PDF
Computer Security - CCNA Security - Lecture 2
Mohamed Loey
 
PDF
Computer Security - CCNA Security - Lecture 1
Mohamed Loey
 
PDF
Algorithms Lecture 8: Pattern Algorithms
Mohamed Loey
 
PDF
Algorithms Lecture 7: Graph Algorithms
Mohamed Loey
 
PDF
Algorithms Lecture 6: Searching Algorithms
Mohamed Loey
 
PDF
Algorithms Lecture 5: Sorting Algorithms II
Mohamed Loey
 
PDF
Algorithms Lecture 4: Sorting Algorithms I
Mohamed Loey
 
PDF
Algorithms Lecture 3: Analysis of Algorithms II
Mohamed Loey
 
PDF
Algorithms Lecture 2: Analysis of Algorithms I
Mohamed Loey
 
PDF
Algorithms Lecture 1: Introduction to Algorithms
Mohamed Loey
 
PDF
Convolutional Neural Network Models - Deep Learning
Mohamed Loey
 
PDF
Deep Learning - Overview of my work II
Mohamed Loey
 
Lecture 6: Deep Learning Applications
Mohamed Loey
 
Lecture 5: Convolutional Neural Network Models
Mohamed Loey
 
Lecture 4: Deep Learning Frameworks
Mohamed Loey
 
Lecture 4: How it Works: Convolutional Neural Networks
Mohamed Loey
 
Lecture 3: Convolutional Neural Networks
Mohamed Loey
 
Lecture 2: Artificial Neural Network
Mohamed Loey
 
Lecture 1: Deep Learning for Computer Vision
Mohamed Loey
 
Design of an Intelligent System for Improving Classification of Cancer Diseases
Mohamed Loey
 
Computer Security - CCNA Security - Lecture 2
Mohamed Loey
 
Computer Security - CCNA Security - Lecture 1
Mohamed Loey
 
Algorithms Lecture 8: Pattern Algorithms
Mohamed Loey
 
Algorithms Lecture 7: Graph Algorithms
Mohamed Loey
 
Algorithms Lecture 6: Searching Algorithms
Mohamed Loey
 
Algorithms Lecture 5: Sorting Algorithms II
Mohamed Loey
 
Algorithms Lecture 4: Sorting Algorithms I
Mohamed Loey
 
Algorithms Lecture 3: Analysis of Algorithms II
Mohamed Loey
 
Algorithms Lecture 2: Analysis of Algorithms I
Mohamed Loey
 
Algorithms Lecture 1: Introduction to Algorithms
Mohamed Loey
 
Convolutional Neural Network Models - Deep Learning
Mohamed Loey
 
Deep Learning - Overview of my work II
Mohamed Loey
 

Recently uploaded (20)

PPTX
Q2 FY26 Tableau User Group Leader Quarterly Call
lward7
 
PDF
“Voice Interfaces on a Budget: Building Real-time Speech Recognition on Low-c...
Edge AI and Vision Alliance
 
PPTX
The Project Compass - GDG on Campus MSIT
dscmsitkol
 
PDF
Kit-Works Team Study_20250627_한달만에만든사내서비스키링(양다윗).pdf
Wonjun Hwang
 
PDF
How do you fast track Agentic automation use cases discovery?
DianaGray10
 
PDF
Transforming Utility Networks: Large-scale Data Migrations with FME
Safe Software
 
PDF
CIFDAQ Market Wrap for the week of 4th July 2025
CIFDAQ
 
PPT
Ericsson LTE presentation SEMINAR 2010.ppt
npat3
 
PDF
LOOPS in C Programming Language - Technology
RishabhDwivedi43
 
PDF
SIZING YOUR AIR CONDITIONER---A PRACTICAL GUIDE.pdf
Muhammad Rizwan Akram
 
PPTX
Agentforce World Tour Toronto '25 - MCP with MuleSoft
Alexandra N. Martinez
 
PDF
Mastering Financial Management in Direct Selling
Epixel MLM Software
 
PDF
NLJUG Speaker academy 2025 - first session
Bert Jan Schrijver
 
PDF
UiPath DevConnect 2025: Agentic Automation Community User Group Meeting
DianaGray10
 
PDF
The 2025 InfraRed Report - Redpoint Ventures
Razin Mustafiz
 
PDF
Reverse Engineering of Security Products: Developing an Advanced Microsoft De...
nwbxhhcyjv
 
PPTX
Agentforce World Tour Toronto '25 - Supercharge MuleSoft Development with Mod...
Alexandra N. Martinez
 
PPTX
Digital Circuits, important subject in CS
contactparinay1
 
PDF
Newgen Beyond Frankenstein_Build vs Buy_Digital_version.pdf
darshakparmar
 
PDF
POV_ Why Enterprises Need to Find Value in ZERO.pdf
darshakparmar
 
Q2 FY26 Tableau User Group Leader Quarterly Call
lward7
 
“Voice Interfaces on a Budget: Building Real-time Speech Recognition on Low-c...
Edge AI and Vision Alliance
 
The Project Compass - GDG on Campus MSIT
dscmsitkol
 
Kit-Works Team Study_20250627_한달만에만든사내서비스키링(양다윗).pdf
Wonjun Hwang
 
How do you fast track Agentic automation use cases discovery?
DianaGray10
 
Transforming Utility Networks: Large-scale Data Migrations with FME
Safe Software
 
CIFDAQ Market Wrap for the week of 4th July 2025
CIFDAQ
 
Ericsson LTE presentation SEMINAR 2010.ppt
npat3
 
LOOPS in C Programming Language - Technology
RishabhDwivedi43
 
SIZING YOUR AIR CONDITIONER---A PRACTICAL GUIDE.pdf
Muhammad Rizwan Akram
 
Agentforce World Tour Toronto '25 - MCP with MuleSoft
Alexandra N. Martinez
 
Mastering Financial Management in Direct Selling
Epixel MLM Software
 
NLJUG Speaker academy 2025 - first session
Bert Jan Schrijver
 
UiPath DevConnect 2025: Agentic Automation Community User Group Meeting
DianaGray10
 
The 2025 InfraRed Report - Redpoint Ventures
Razin Mustafiz
 
Reverse Engineering of Security Products: Developing an Advanced Microsoft De...
nwbxhhcyjv
 
Agentforce World Tour Toronto '25 - Supercharge MuleSoft Development with Mod...
Alexandra N. Martinez
 
Digital Circuits, important subject in CS
contactparinay1
 
Newgen Beyond Frankenstein_Build vs Buy_Digital_version.pdf
darshakparmar
 
POV_ Why Enterprises Need to Find Value in ZERO.pdf
darshakparmar
 

PHP Comprehensive Overview

  • 2. Agenda  Part I: Introduction  Part II: PHP Syntax  Part III: PHP Form Handling
  • 3. Agenda  Part I: Introduction  What is PHP?  Why we use PHP?  PHP Can  Set Up PHP on Your Own PC
  • 4. What is PHP?  PHP is a server scripting language, and is a powerful tool for making dynamic and interactive Web pages quickly.  PHP is a widely-used, open source scripting language  PHP scripts are executed on the server  PHP costs nothing, it is free to download and use
  • 5. Why we use PHP?  PHP runs on various platforms (Windows, Linux, Unix, Mac OS X, etc.)  PHP is compatible with almost all servers used today (Apache, IIS, etc.)  PHP supports a wide range of databases  PHP is easy to learn and runs efficiently on the server side  It is powerful enough to be at the core of the biggest blogging system on the web (WordPress)!  It is deep enough to run the largest social network (Facebook)!
  • 6. PHP Can  Generate dynamic page content  Create, open, read, write, delete, and close files on the server  Send and receive cookies  Add, delete, modify data in your database  Encrypt data  Output images, PDF files, and even Flash movies
  • 7. Set Up PHP on Your Own PC  Install a web server (Apache)  Install PHP  Install a database, such as MySQL  Example: XAMPP (Apache + MySQL + PHP + Perl)  XAMPP is the most popular PHP development environment
  • 8. Agenda  Part II: PHP Syntax  PHP Syntax  Comments in PHP  PHP Case Sensitivity  PHP Variables  PHP echo and print Statements  PHP Operators  PHP Conditional Statements  PHP Loops  PHP Functions  PHP Arrays
  • 9. PHP Syntax  PHP script can be placed anywhere in the document.  A PHP script starts with <?php and ends with ?>  The default file extension for PHP files is ".php".
  • 11. Comments in PHP  A comment in PHP code is a line that is not read/executed as part of the program.  PHP supports three ways of commenting:
  • 12. PHP Case Sensitivity  In PHP, all user-defined functions, classes, and keywords (e.g. if, else, while, echo, etc.) are NOT case- sensitive.  Example:
  • 13. PHP Case Sensitivity  However; in PHP, all variables are case- sensitive.  $color, $COLOR, and $coLOR are treated as three different variables  Example:
  • 14. PHP Variables  Variables are "containers" for storing information.  A variable starts with the $ sign, followed by the name of the variable  A variable name must start with a letter or the underscore character  A variable name cannot start with a number  A variable name can only contain alpha- numeric characters and underscores (A-z, 0-9, and _ )  Variable names are case sensitive ($y and $Y are two different variables)
  • 15. PHP Variables  PHP has no command for declaring a variable.  Example:
  • 16. PHP echo and print Statements  In PHP there are two basic ways to get output: echo and print.  There are some differences between echo and print:  echo - can output one or more strings  print - can only output one string, and returns always 1  Example:
  • 17. PHP Operators  PHP Arithmetic Operators
  • 18. PHP Operators  PHP Arithmetic Operators Example:
  • 19. PHP Operators  PHP Assignment Operators
  • 20. PHP Operators  PHP Assignment Operators Example:
  • 21. PHP Operators  PHP String Operators
  • 22. PHP Operators  PHP String Operators Example:
  • 23. PHP Operators  PHP Increment / Decrement Operators
  • 24. PHP Operators  PHP Increment / Decrement Operators Example:
  • 25. PHP Operators  PHP Comparison Operators
  • 26. PHP Operators  PHP Comparison Operators Example:
  • 27. PHP Operators  PHP Logical Operators
  • 28. PHP Operators  PHP Array Operators
  • 29. PHP Operators  PHP Array Operators Example:
  • 30. PHP Conditional Statements  In PHP we have the following conditional statements:  if statement - executes some code only if a specified condition is true  if...else statement - executes some code if a condition is true and another code if the condition is false  if...elseif....else statement - selects one of several blocks of code to be executed  switch statement - selects one of many blocks of code to be executed
  • 31. PHP Conditional Statements  If else Example:
  • 33. PHP Loops  In PHP, we have the following looping statements:  while - loops through a block of code as long as the specified condition is true  do...while - loops through a block of code once, and then repeats the loop as long as the specified 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
  • 34. PHP Loops  PHP while Loop example:
  • 35. PHP Loops  PHP do...while Loop example:
  • 36. PHP Loops  PHP for Loop example:
  • 37. PHP Loops  PHP foreach Loop example:
  • 38. PHP Functions  A function is a block of statements that can be used repeatedly in a program.  A function will not execute immediately when a page loads.  A function will be executed by a call to the function.
  • 39. PHP Functions  PHP function examples:
  • 40. PHP Arrays  An array is a special variable, which can hold more than one value at a time.  Example:
  • 41. PHP Associative Arrays  Associative arrays are arrays that use named keys that you assign to them.  Example:
  • 42. PHP Sorting Arrays  PHP array sort functions:  sort() - sort arrays in ascending order  rsort() - sort arrays in descending order  asort() - sort associative arrays in ascending order, according to the value  ksort() - sort associative arrays in ascending order, according to the key  arsort() - sort associative arrays in descending order, according to the value  krsort() - sort associative arrays in descending order, according to the key
  • 43. Agenda  Part III: PHP Form Handling  PHP GET vs. POST  PHP $_GET  PHP $_POST
  • 44. PHP Form Handling  One of the most powerful features of PHP is the way it handles HTML forms. The basic concept that is important to understand is that any form element will automatically be available to your PHP scripts.  The PHP $_GET and $_POST are used to collect form-data.
  • 45. PHP GET vs. POST  Both GET and POST create an array (e.g. array( key => value, key2 => value2, key3 => value3, ...)). This array holds key/value pairs, where keys are the names of the form controls and values are the input data from the user.  When to use GET?  Information sent from a form with the GET method is visible to everyone  facebook.com?welcome.php?name=Mohamed  When to use POST?  Information sent from a form with the POST method is invisible to others  facebook.com?welcome.php
  • 47. PHP $_GET  When the user fills out the form above and clicks the submit button, the form data is sent for processing to a PHP file named "welcome.php".  welcome.php
  • 48. PHP $_GET  Result:  Welocome.php Output
  • 50. PHP $_POST  When the user fills out the form above and clicks the submit button, the form data is sent for processing to a PHP file named "welcome.php".  welcome.php
  • 51. PHP $_POST  Result:  Welocome.php Output