The document provides an introduction to PHP including:
- PHP is an open source scripting language especially suited for web development and can be embedded into HTML.
- PHP code is executed on the server, generating HTML which is then sent to the client.
- PHP supports variables, operators, conditional statements, arrays, loops, functions, and forms. Key functions like $_GET and $_POST are used to collect form data submitted via GET and POST methods respectively.
This document provides an introduction to PHP through a slideshow presentation. It covers key topics like PHP basics, variables, operators, conditional statements, arrays, loops, and functions. It also discusses using PHP with forms and the $_GET and $_POST functions. The presentation is designed to teach PHP fundamentals and get users started with the language through examples and explanations on each slide.
This document provides an introduction to PHP by summarizing its key features and concepts over several slides:
- PHP is an open source scripting language suited for web development that is embedded into HTML. It processes scripts on the server and generates HTML sent to the client.
- The document covers PHP basics like syntax, variables, operators, conditional statements, arrays, and loops. It provides examples to illustrate each concept.
- Resources like WAMP and MAMP are recommended for setting up a local development environment to run PHP scripts and connect to databases like MySQL.
This document provides an introduction to PHP through a slideshow presentation. It covers key topics like PHP basics, variables, operators, conditional statements, arrays, loops, and functions. It also discusses using PHP with forms and the $_GET and $_POST functions. The presentation is designed to teach PHP fundamentals and get users started with the language through examples and explanations of core concepts.
This document introduces PHP through a slideshow presentation. It begins with an overview of PHP, explaining that it is a widely-used scripting language suited for web development. It then covers PHP fundamentals like variables, data types, operators, conditional statements, arrays, loops, and functions. The document also demonstrates how to collect form data submitted via the GET and POST methods in PHP. Overall, the presentation provides a high-level introduction to key PHP concepts for beginners.
This document provides an introduction to PHP by explaining some of its key features and concepts:
- PHP is a widely-used open source scripting language suited for web development that is embedded into HTML. It runs on servers and generates HTML sent to clients.
- It supports many databases and runs on different platforms. PHP code is enclosed in <?php ?> tags and variables start with $. Conditional statements like if/else and loops like while are used to control program flow.
- Arrays can store multiple values in one variable and come in numeric, associative, and multidimensional forms. Key PHP concepts covered include variables, operators, and basic syntax for comments, strings, and functions.
This document provides an introduction to PHP by explaining some key concepts:
- PHP is a widely-used scripting language especially for web development that is embedded into HTML.
- It is free and runs on many platforms and servers.
- Examples demonstrate basic PHP syntax like variables, operators, conditional statements, arrays, and loops.
- Key points about installing PHP, writing "Hello World" scripts, and using comments, variables, concatenation, and data types are covered at a high level.
- The document provides an overview of different statements like if/else, switch, while, do/while, for, and foreach with simple examples.
This document provides an overview of PHP basics including:
- What PHP is and how it works as a server-side scripting language
- The basic structure of PHP files and how PHP code is executed
- Common PHP syntax like variables, data types, operators, conditional statements, loops, arrays, and functions
- How to handle forms and user input with the $_GET, $_POST, and $_REQUEST superglobals
- Examples of basic PHP scripts and code snippets
The document is intended as an introduction to PHP for beginners, covering the essential concepts needed to get started with the language.
This document provides an introduction to PHP sessions. It explains that PHP sessions allow a website to store and display user information, determine user groups, and manage permissions. Sessions are important for these features. The document notes that cookies are becoming less reliable due to increasing browser security and privacy settings, but PHP sessions can achieve similar functionality as cookies in a way that does not store data locally on user devices.
The document provides an introduction to PHP, covering key topics such as:
- PHP is a server-side scripting language that supports many databases and runs on different platforms.
- PHP scripts are contained within <?php ?> tags and can be embedded in HTML files or call HTML from PHP files.
- Variables start with $, support different data types, and can be concatenated.
- PHP supports common programming constructs like conditional statements, loops, arrays, and functions.
- Form data submitted to PHP pages is accessible via the $_GET and $_POST superglobal arrays.
This document provides an introduction to PHP and web development using PHP. It covers:
- An overview of PHP and its history and alternatives
- PHP syntax including variables, operators, conditional statements, arrays, loops, and functions
- How PHP scripts are executed on the server and integrated with HTML
- Using PHP to work with forms and retrieve data submitted via GET and POST methods
This document provides an introduction to PHP, covering its history, parsing, variables, arrays, operators, functions, control structures, and use of external data files. PHP is an open-source server-side scripting language that was originally created in 1994 and is widely used for web development. It allows developers to embed code into HTML pages that is executed on the server to dynamically generate content.
The document discusses PHP concepts including:
- PHP is a server-side scripting language used for web development and can be used as an alternative to Microsoft ASP.
- XAMPP is an open-source cross-platform web server bundle that can be used to test PHP scripts locally.
- PHP has different data types including strings, integers, floats, booleans, and arrays.
- PHP includes various operators, conditional statements like if/else, and loops like while and foreach to control program flow.
- Functions allow code reusability and modularity in PHP programs. Built-in and user-defined functions are discussed.
- Arrays are a special variable type that can hold multiple values,
PHP Basics is a presentation that introduces PHP. It discusses that PHP is a server-side scripting language used for building dynamic websites. It can be embedded into HTML. When a PHP file is requested, the server processes the PHP code and returns the output to the browser as HTML. The presentation covers PHP syntax, variables, data types, operators, functions, and conditional statements. It provides examples to illustrate basic PHP concepts and functionality.
PHP is a server-side scripting language used for web development. It allows developers to add dynamic content and functionality to websites. Some key points about PHP from the document:
- PHP code is embedded into HTML and executed on the server to create dynamic web page content. It can be used to connect to databases, process forms, and more.
- PHP has many data types including strings, integers, floats, booleans, arrays, objects, null values and resources. Variables, operators, and conditional statements allow for control flow and data manipulation.
- Common PHP structures include if/else statements for conditional logic, loops like for/while/foreach for iteration, and functions for reusability. Ar
The document provides an overview of basic PHP syntax and concepts, including:
1. PHP scripting blocks start with <?php and end with ?>. Variables, comments, and code lines must follow certain syntax rules.
2. Variables can store different data types and are declared with a $ sign. Arrays allow storing multiple values in one variable and can be numeric, associative, or multidimensional.
3. Common functions for manipulating strings include concatenation, finding length and position. Switch statements and loops like while are used for conditional logic and repetition.
This document provides an introduction and overview of PHP and MySQL. PHP is a programming language used for building dynamic web sites. It allows embedding code within HTML pages to quickly create dynamic content. PHP is processed on the server side to produce HTML results. The document outlines PHP basics like syntax, variables, strings, operators, and conditional statements. It also discusses MySQL, the most popular database used with PHP. The document concludes with exercises for users to practice basic PHP concepts.
The document provides an agenda for a one day PHP workshop. The agenda includes an introduction to PHP, instructions on how to install PHP, and an example getting started with PHP. Some key topics that will be covered are PHP basics like variables, arrays, loops, and functions. The workshop aims to get participants up and running with PHP from start to finish in a single day.
Php classes in mumbai
best Php classes in mumbai with job assistance.
our features are:
expert guidance by it industry professionals
lowest fees of 5000
practical exposure to handle projects
well equiped lab
after course resume writing guidance
How to Manage & Create a New Department in Odoo 18 EmployeeCeline George
In Odoo 18's Employee module, organizing your workforce into departments enhances management and reporting efficiency. Departments are a crucial organizational unit within the Employee module.
How to Configure Vendor Management in Lunch App of Odoo 18Celine George
The Vendor management in the Lunch app of Odoo 18 is the central hub for managing all aspects of the restaurants or caterers that provide food for your employees.
More Related Content
Similar to introduction to php web programming 2024.ppt (20)
This document provides an overview of PHP basics including:
- What PHP is and how it works as a server-side scripting language
- The basic structure of PHP files and how PHP code is executed
- Common PHP syntax like variables, data types, operators, conditional statements, loops, arrays, and functions
- How to handle forms and user input with the $_GET, $_POST, and $_REQUEST superglobals
- Examples of basic PHP scripts and code snippets
The document is intended as an introduction to PHP for beginners, covering the essential concepts needed to get started with the language.
This document provides an introduction to PHP sessions. It explains that PHP sessions allow a website to store and display user information, determine user groups, and manage permissions. Sessions are important for these features. The document notes that cookies are becoming less reliable due to increasing browser security and privacy settings, but PHP sessions can achieve similar functionality as cookies in a way that does not store data locally on user devices.
The document provides an introduction to PHP, covering key topics such as:
- PHP is a server-side scripting language that supports many databases and runs on different platforms.
- PHP scripts are contained within <?php ?> tags and can be embedded in HTML files or call HTML from PHP files.
- Variables start with $, support different data types, and can be concatenated.
- PHP supports common programming constructs like conditional statements, loops, arrays, and functions.
- Form data submitted to PHP pages is accessible via the $_GET and $_POST superglobal arrays.
This document provides an introduction to PHP and web development using PHP. It covers:
- An overview of PHP and its history and alternatives
- PHP syntax including variables, operators, conditional statements, arrays, loops, and functions
- How PHP scripts are executed on the server and integrated with HTML
- Using PHP to work with forms and retrieve data submitted via GET and POST methods
This document provides an introduction to PHP, covering its history, parsing, variables, arrays, operators, functions, control structures, and use of external data files. PHP is an open-source server-side scripting language that was originally created in 1994 and is widely used for web development. It allows developers to embed code into HTML pages that is executed on the server to dynamically generate content.
The document discusses PHP concepts including:
- PHP is a server-side scripting language used for web development and can be used as an alternative to Microsoft ASP.
- XAMPP is an open-source cross-platform web server bundle that can be used to test PHP scripts locally.
- PHP has different data types including strings, integers, floats, booleans, and arrays.
- PHP includes various operators, conditional statements like if/else, and loops like while and foreach to control program flow.
- Functions allow code reusability and modularity in PHP programs. Built-in and user-defined functions are discussed.
- Arrays are a special variable type that can hold multiple values,
PHP Basics is a presentation that introduces PHP. It discusses that PHP is a server-side scripting language used for building dynamic websites. It can be embedded into HTML. When a PHP file is requested, the server processes the PHP code and returns the output to the browser as HTML. The presentation covers PHP syntax, variables, data types, operators, functions, and conditional statements. It provides examples to illustrate basic PHP concepts and functionality.
PHP is a server-side scripting language used for web development. It allows developers to add dynamic content and functionality to websites. Some key points about PHP from the document:
- PHP code is embedded into HTML and executed on the server to create dynamic web page content. It can be used to connect to databases, process forms, and more.
- PHP has many data types including strings, integers, floats, booleans, arrays, objects, null values and resources. Variables, operators, and conditional statements allow for control flow and data manipulation.
- Common PHP structures include if/else statements for conditional logic, loops like for/while/foreach for iteration, and functions for reusability. Ar
The document provides an overview of basic PHP syntax and concepts, including:
1. PHP scripting blocks start with <?php and end with ?>. Variables, comments, and code lines must follow certain syntax rules.
2. Variables can store different data types and are declared with a $ sign. Arrays allow storing multiple values in one variable and can be numeric, associative, or multidimensional.
3. Common functions for manipulating strings include concatenation, finding length and position. Switch statements and loops like while are used for conditional logic and repetition.
This document provides an introduction and overview of PHP and MySQL. PHP is a programming language used for building dynamic web sites. It allows embedding code within HTML pages to quickly create dynamic content. PHP is processed on the server side to produce HTML results. The document outlines PHP basics like syntax, variables, strings, operators, and conditional statements. It also discusses MySQL, the most popular database used with PHP. The document concludes with exercises for users to practice basic PHP concepts.
The document provides an agenda for a one day PHP workshop. The agenda includes an introduction to PHP, instructions on how to install PHP, and an example getting started with PHP. Some key topics that will be covered are PHP basics like variables, arrays, loops, and functions. The workshop aims to get participants up and running with PHP from start to finish in a single day.
Php classes in mumbai
best Php classes in mumbai with job assistance.
our features are:
expert guidance by it industry professionals
lowest fees of 5000
practical exposure to handle projects
well equiped lab
after course resume writing guidance
How to Manage & Create a New Department in Odoo 18 EmployeeCeline George
In Odoo 18's Employee module, organizing your workforce into departments enhances management and reporting efficiency. Departments are a crucial organizational unit within the Employee module.
How to Configure Vendor Management in Lunch App of Odoo 18Celine George
The Vendor management in the Lunch app of Odoo 18 is the central hub for managing all aspects of the restaurants or caterers that provide food for your employees.
This presentation was provided by Nicole 'Nici" Pfeiffer of the Center for Open Science (COS), during the first session of our 2025 NISO training series "Secrets to Changing Behavior in Scholarly Communications." Session One was held June 5, 2025.
How to Create Quotation Templates Sequence in Odoo 18 SalesCeline George
In this slide, we’ll discuss on how to create quotation templates sequence in Odoo 18 Sales. Odoo 18 Sales offers a variety of quotation templates that can be used to create different types of sales documents.
Human Anatomy and Physiology II Unit 3 B pharm Sem 2
Respiratory system
Anatomy of respiratory system with special reference to anatomy
of lungs, mechanism of respiration, regulation of respiration
Lung Volumes and capacities transport of respiratory gases,
artificial respiration, and resuscitation methods
Urinary system
Anatomy of urinary tract with special reference to anatomy of
kidney and nephrons, functions of kidney and urinary tract,
physiology of urine formation, micturition reflex and role of
kidneys in acid base balance, role of RAS in kidney and
disorders of kidney
How to Manage Maintenance Request in Odoo 18Celine George
Efficient maintenance management is crucial for keeping equipment and work centers running smoothly in any business. Odoo 18 provides a Maintenance module that helps track, schedule, and manage maintenance requests efficiently.
Different pricelists for different shops in odoo Point of Sale in Odoo 17Celine George
Price lists are a useful tool for managing the costs of your goods and services. This can assist you in working with other businesses effectively and maximizing your revenues. Additionally, you can provide your customers discounts by using price lists.
Pests of Rice: Damage, Identification, Life history, and Management.pptxArshad Shaikh
Rice pests can significantly impact crop yield and quality. Major pests include the brown plant hopper (Nilaparvata lugens), which transmits viruses like rice ragged stunt and grassy stunt; the yellow stem borer (Scirpophaga incertulas), whose larvae bore into stems causing deadhearts and whiteheads; and leaf folders (Cnaphalocrocis medinalis), which feed on leaves reducing photosynthetic area. Other pests include rice weevils (Sitophilus oryzae) and gall midges (Orseolia oryzae). Effective management strategies are crucial to minimize losses.
How to Manage Upselling of Subscriptions in Odoo 18Celine George
Subscriptions in Odoo 18 are designed to auto-renew indefinitely, ensuring continuous service for customers. However, businesses often need flexibility to adjust pricing or quantities based on evolving customer needs.
How to Create an Event in Odoo 18 - Odoo 18 SlidesCeline George
Creating an event in Odoo 18 is a straightforward process that allows you to manage various aspects of your event efficiently.
Odoo 18 Events Module is a powerful tool for organizing and managing events of all sizes, from conferences and workshops to webinars and meetups.
This presentation has been made keeping in mind the students of undergraduate and postgraduate level. To keep the facts in a natural form and to display the material in more detail, the help of various books, websites and online medium has been taken. Whatever medium the material or facts have been taken from, an attempt has been made by the presenter to give their reference at the end.
In the seventh century, the rule of Sindh state was in the hands of Rai dynasty. We know the names of five kings of this dynasty- Rai Divji, Rai Singhras, Rai Sahasi, Rai Sihras II and Rai Sahasi II. During the time of Rai Sihras II, Nimruz of Persia attacked Sindh and killed him. After the return of the Persians, Rai Sahasi II became the king. After killing him, one of his Brahmin ministers named Chach took over the throne. He married the widow of Rai Sahasi and became the ruler of entire Sindh by suppressing the rebellions of the governors.
Artificial intelligence Presented by JM.jmansha170
AI (Artificial Intelligence) :
"AI is the ability of machines to mimic human intelligence, such as learning, decision-making, and problem-solving."
Important Points about AI:
1. Learning – AI can learn from data (Machine Learning).
2. Automation – It helps automate repetitive tasks.
3. Decision Making – AI can analyze and make decisions faster than humans.
4. Natural Language Processing (NLP) – AI can understand and generate human language.
5. Vision & Recognition – AI can recognize images, faces, and patterns.
6. Used In – Healthcare, finance, robotics, education, and more.
Owner By:
Name : Junaid Mansha
Work : Web Developer and Graphics Designer
Contact us : +92 322 2291672
Email : [email protected]
Energy Balances Of Oecd Countries 2011 Iea Statistics 1st Edition Oecdrazelitouali
Energy Balances Of Oecd Countries 2011 Iea Statistics 1st Edition Oecd
Energy Balances Of Oecd Countries 2011 Iea Statistics 1st Edition Oecd
Energy Balances Of Oecd Countries 2011 Iea Statistics 1st Edition Oecd
Trends Spotting Strategic foresight for tomorrow’s education systems - Debora...EduSkills OECD
Deborah Nusche, Senior Analyst, OECD presents at the OECD webinar 'Trends Spotting: Strategic foresight for tomorrow’s education systems' on 5 June 2025. You can check out the webinar on the website https://oecdedutoday.com/webinars/ Other speakers included: Deborah Nusche, Senior Analyst, OECD
Sophie Howe, Future Governance Adviser at the School of International Futures, first Future Generations Commissioner for Wales (2016-2023)
Davina Marie, Interdisciplinary Lead, Queens College London
Thomas Jørgensen, Director for Policy Coordination and Foresight at European University Association
3. Welcome
This slideshow presentation is designed to
introduce you to PHP. It is the first of two
PHP workshops available at
www.tinyurl.com/rpi123. In addition to the
two PHP workshops, there are also
workshops on HMTL and CSS.
These slides are based on source material found at the w3schools.com website.
You are encouraged to visit the site – it is a great resource.
4. Caveat
PHP and MySQL are tricky to teach without
access to a server and a database. We'll do the
best we can in the slides that follow.
They are also tricky considering how complex
they are. Take a look at the PHP cheat sheet I
found online...
8. PHP Introduction
> PHP runs on different platforms (Windows,
Linux, Unix, etc.)
> PHP is compatible with almost all servers used
today (Apache, IIS, etc.)
> PHP is FREE to download from the official PHP
resource: www.php.net
> PHP is easy to learn and runs efficiently on the
server side
10. PHP Introduction
Instead of lots of commands to output HTML (as
seen in C or Perl), PHP pages contain HTML with
embedded code that does "something" (like in the
next slide, it outputs "Hi, I'm a PHP script!").
The PHP code is enclosed in special start and
end processing instructions <?php and ?> that
allow you to jump into and out of "PHP mode."
12. PHP Introduction
PHP code is executed on the server, generating
HTML which is then sent to the client. The client
would receive the results of running that script, but
would not know what the underlying code was.
A visual, if you please...
14. PHP Getting Started
On windows, you can download and install
WAMP. With one installation and you get an
Apache webserver, database server and php.
http://www.wampserver.com
On mac, you can download and install MAMP.
http://www.mamp.info/en/index.html
17. PHP Hello World
This program is extremely simple and you really
did not need to use PHP to create a page like this.
All it does is display: Hello World using the PHP
echo() statement.
Think of this as a normal HTML file which
happens to have a set of special tags available to
you that do a lot of interesting things.
18. PHP Comments
In PHP, we use // to
make a single-line
comment or /* and */ to
make a large comment
block.
20. PHP Variables
> In PHP, a variable does not need to be declared
before adding a value to it.
> In the example above, you see that you do not
have to tell PHP which data type the variable is.
> PHP automatically converts the variable to the
correct data type, depending on its value.
22. PHP Concatenation
> The concatenation operator (.) is used to put
two string values together.
> To concatenate two string variables together,
use the concatenation operator:
23. PHP Concatenation
The output of the code on the last slide will be:
If we look at the code you see that we used the
concatenation operator two times. This is because
we had to insert a third string (a space character),
to separate the two strings.
24. PHP Operators
Operators are used to operate on values. There
are four classifications of operators:
> Arithmetic
> Assignment
> Comparison
> Logical
29. PHP Conditional Statements
> Very often when you write code, you want to
perform different actions for different decisions.
> You can use conditional statements in your
code to do this.
> In PHP we have the following conditional
statements...
30. PHP Conditional Statements
> if statement - use this statement to execute
some code only if a specified condition is true
> if...else statement - use this statement to
execute some code if a condition is true and
another code if the condition is false
> if...elseif....else statement - use this statement
to select one of several blocks of code to be
executed
> switch statement - use this statement to select
one of many blocks of code to be executed
32. PHP Conditional Statements
Use the if....else statement to execute some code
if a condition is true and another code if a
condition is false.
33. PHP Conditional Statements
If more than one line
should be executed if a
condition is true/false,
the lines should be
enclosed within curly
braces { }
34. PHP Conditional Statements
The following example
will output "Have a nice
weekend!" if the current
day is Friday, and "Have
a nice Sunday!" if the
current day is Sunday.
Otherwise it will output
"Have a nice day!":
36. PHP Conditional Statements
For switches, first we have a single expression n
(most often a variable), that is evaluated once.
The value of the expression is then compared with
the values for each case in the structure. If there
is a match, the block of code associated with that
case is executed.
Use break to prevent the code from running into
the next case automatically. The default statement
is used if no match is found.
38. PHP Arrays
> An array variable is a storage area holding a
number or text. The problem is, a variable will hold
only one value.
> An array is a special variable, which can store
multiple values in one single variable.
39. PHP Arrays
If you have a list of items (a list of car names, for
example), storing the cars in single variables
could look like this:
40. PHP Arrays
> However, what if you want to loop through the
cars and find a specific one? And what if you had
not 3 cars, but 300?
> The best solution here is to use an array.
> An array can hold all your variable values under
a single name. And you can access the values by
referring to the array name.
> Each element in the array has its own index so
that it can be easily accessed.
41. PHP Arrays
In PHP, there are three kind of arrays:
> Numeric array - An array with a numeric index
> Associative array - An array where each ID
key is associated with a value
> Multidimensional array - An array containing
one or more arrays
42. PHP Numeric Arrays
> A numeric array stores each array element with
a numeric index.
> There are two methods to create a numeric
array.
43. PHP Numeric Arrays
In the following example the index is automatically
assigned (the index starts at 0):
In the following example we assign the index
manually:
44. PHP Numeric Arrays
In the following example you access the variable
values by referring to the array name and index:
The code above will output:
45. PHP Associative Arrays
> With an associative array, each ID key is
associated with a value.
> When storing data about specific named values,
a numerical array is not always the best way to do
it.
> With associative arrays we can use the values
as keys and assign values to them.
46. PHP Associative Arrays
In this example we use an array to assign ages to
the different persons:
This example is the same as the one above, but
shows a different way of creating the array:
48. PHP Multidimensional Arrays
In a multidimensional array, each element in the
main array can also be an array.
And each element in the sub-array can be an
array, and so on.
52. PHP Loops
> Often when you write code, you want the same
block of code to run over and over again in a row.
Instead of adding several almost equal lines in a
script we can use loops to perform a task like this.
> In PHP, we have the following looping
statements:
53. PHP Loops
> while - loops through a block of code while a
specified condition is true
> do...while - loops through a block of code once,
and then repeats the loop as long as a 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
54. PHP Loops - While
The while loop executes a block of code while a
condition is true. The example below defines a
loop that starts with
i=1. The loop will
continue to run as
long as i is less
than, or equal to 5.
i will increase by 1
each time the loop
runs:
56. PHP Loops – Do ... While
The do...while statement will always execute the
block of code once, it will then check the
condition, and repeat the loop while the condition
is true.
The next example defines a loop that starts with
i=1. It will then increment i with 1, and write some
output. Then the condition is checked, and the
loop will continue to run as long as i is less than,
or equal to 5:
60. PHP Loops - For
Parameters:
> init: Mostly used to set a counter (but can be
any code to be executed once at the beginning
of the loop)
> condition: Evaluated for each loop iteration. If it
evaluates to TRUE, the loop continues. If it
evaluates to FALSE, the loop ends.
> increment: Mostly used to increment a counter
(but can be any code to be executed at the end
of the loop)
61. PHP Loops - For
The example below defines a loop that starts with
i=1. The loop will continue to run as long as i is
less than, or equal to 5. i will increase by 1 each
time the loop runs:
63. PHP Loops - Foreach
For every loop iteration, the value of the current
array element is assigned to $value (and the array
pointer is moved by one) - so on the next loop
iteration, you'll be looking at the next array value.
64. PHP Loops - Foreach
The following example demonstrates a loop that
will print the values of the given array:
65. PHP Loops - Foreach
Winner of the most impressive slide award
66. PHP Functions
> We will now explore how to create your own
functions.
> To keep the script from being executed when
the page loads, you can put it into a function.
> A function will be executed by a call to the
function.
> You may call a function from anywhere within a
page.
67. PHP Functions
A function will be executed by a call to the
function.
> Give the function a name that reflects what the
function does
> The function name can start with a letter or
underscore (not a number)
69. PHP Functions - Parameters
Adding parameters...
> To add more functionality to a function, we can
add parameters. A parameter is just like a
variable.
> Parameters are specified after the function
name, inside the parentheses.
75. PHP Forms - $_GET Function
Notice how the URL carries the information after the file name.
76. PHP Forms - $_GET Function
The "welcome.php" file can now use the $_GET
function to collect form data (the names of the
form fields will automatically be the keys in the
$_GET array)
77. PHP Forms - $_GET Function
> When using method="get" in HTML forms, all
variable names and values are displayed in the URL.
> This method should not be used when sending
passwords or other sensitive information!
> However, because the variables are displayed in
the URL, it is possible to bookmark the page. This
can be useful in some cases.
> The get method is not suitable for large variable
values; the value cannot exceed 100 chars.
78. PHP Forms - $_POST Function
> The built-in $_POST function is used to collect
values from a form sent with method="post".
> Information sent from a form with the POST
method is invisible to others and has no limits on
the amount of information to send.
> Note: However, there is an 8 Mb max size for
the POST method, by default (can be changed by
setting the post_max_size in the php.ini file).
79. PHP Forms - $_POST Function
And here is what the code of action.php might look like:
80. PHP Forms - $_POST Function
Apart from htmlspecialchars() and (int), it should
be obvious what this does. htmlspecialchars()
makes sure any characters that are special in html
are properly encoded so people can't inject HTML
tags or Javascript into your page.
For the age field, since we know it is a number,
we can just convert it to an integer which will
automatically get rid of any stray characters. The
$_POST['name'] and $_POST['age'] variables
are automatically set for you by PHP.
81. PHP Forms - $_POST Function
When to use method="post"?
> Information sent from a form with the POST
method is invisible to others and has no limits
on the amount of information to send.
> However, because the variables are not
displayed in the URL, it is not possible to
bookmark the page.