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
Abu Bakar
 
PPT
Php i-slides (2) (1)
ravi18011991
 
PPT
Php i-slides
zalatarunk
 
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-I-slides.ppt
SsewankamboErma
 
PPT
PHP InterLevel.ppt
NBACriteria2SICET
 
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
Abu Bakar
 
Php i-slides (2) (1)
ravi18011991
 
Php i-slides
zalatarunk
 
Php i-slides
ravi18011991
 
Introduction of PHP.pdf
karinaabyys
 
PHP - Introduction to PHP - Mazenet Solution
Mazenetsolution
 
Day1
IRWAA LLC
 
php41.ppt
Nishant804733
 
php-I-slides.ppt
SsewankamboErma
 
PHP InterLevel.ppt
NBACriteria2SICET
 
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)

PDF
Lecture A - AI Workflows for Banking.pdf
Dr. LAM Yat-fai (林日辉)
 
PDF
Structs to JSON: How Go Powers REST APIs
Emily Achieng
 
PPTX
Introduction to Flutter by Ayush Desai.pptx
ayushdesai204
 
PDF
Per Axbom: The spectacular lies of maps
Nexer Digital
 
PDF
Economic Impact of Data Centres to the Malaysian Economy
flintglobalapac
 
PDF
Market Insight : ETH Dominance Returns
CIFDAQ
 
PPTX
Farrell_Programming Logic and Design slides_10e_ch02_PowerPoint.pptx
bashnahara11
 
PDF
TrustArc Webinar - Navigating Data Privacy in LATAM: Laws, Trends, and Compli...
TrustArc
 
PDF
State-Dependent Conformal Perception Bounds for Neuro-Symbolic Verification
Ivan Ruchkin
 
PPTX
Agile Chennai 18-19 July 2025 | Emerging patterns in Agentic AI by Bharani Su...
AgileNetwork
 
PDF
Presentation about Hardware and Software in Computer
snehamodhawadiya
 
PPTX
The Future of AI & Machine Learning.pptx
pritsen4700
 
PPTX
IT Runs Better with ThousandEyes AI-driven Assurance
ThousandEyes
 
PDF
GDG Cloud Munich - Intro - Luiz Carneiro - #BuildWithAI - July - Abdel.pdf
Luiz Carneiro
 
PDF
Tea4chat - another LLM Project by Kerem Atam
a0m0rajab1
 
PDF
Researching The Best Chat SDK Providers in 2025
Ray Fields
 
PDF
RAT Builders - How to Catch Them All [DeepSec 2024]
malmoeb
 
PDF
NewMind AI Weekly Chronicles – July’25, Week III
NewMind AI
 
PPTX
Dev Dives: Automate, test, and deploy in one place—with Unified Developer Exp...
AndreeaTom
 
PPTX
Applied-Statistics-Mastering-Data-Driven-Decisions.pptx
parmaryashparmaryash
 
Lecture A - AI Workflows for Banking.pdf
Dr. LAM Yat-fai (林日辉)
 
Structs to JSON: How Go Powers REST APIs
Emily Achieng
 
Introduction to Flutter by Ayush Desai.pptx
ayushdesai204
 
Per Axbom: The spectacular lies of maps
Nexer Digital
 
Economic Impact of Data Centres to the Malaysian Economy
flintglobalapac
 
Market Insight : ETH Dominance Returns
CIFDAQ
 
Farrell_Programming Logic and Design slides_10e_ch02_PowerPoint.pptx
bashnahara11
 
TrustArc Webinar - Navigating Data Privacy in LATAM: Laws, Trends, and Compli...
TrustArc
 
State-Dependent Conformal Perception Bounds for Neuro-Symbolic Verification
Ivan Ruchkin
 
Agile Chennai 18-19 July 2025 | Emerging patterns in Agentic AI by Bharani Su...
AgileNetwork
 
Presentation about Hardware and Software in Computer
snehamodhawadiya
 
The Future of AI & Machine Learning.pptx
pritsen4700
 
IT Runs Better with ThousandEyes AI-driven Assurance
ThousandEyes
 
GDG Cloud Munich - Intro - Luiz Carneiro - #BuildWithAI - July - Abdel.pdf
Luiz Carneiro
 
Tea4chat - another LLM Project by Kerem Atam
a0m0rajab1
 
Researching The Best Chat SDK Providers in 2025
Ray Fields
 
RAT Builders - How to Catch Them All [DeepSec 2024]
malmoeb
 
NewMind AI Weekly Chronicles – July’25, Week III
NewMind AI
 
Dev Dives: Automate, test, and deploy in one place—with Unified Developer Exp...
AndreeaTom
 
Applied-Statistics-Mastering-Data-Driven-Decisions.pptx
parmaryashparmaryash
 

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