Professional Documents
Culture Documents
Lec 03 PHP Basics Part 3 PDF
Lec 03 PHP Basics Part 3 PDF
Functions, Forms
Functions
What are Functions?
Built-in Functions
• PHP has a huge collection of internal or built-in
functions that you can call directly within your PHP
scripts to perform a specific task, like date(),
print_r(), var_dump(), etc.
Types of Functions
User-defined Functions
• PHP also allows you to define your own functions. It
is a way to create reusable code packages that
perform specific tasks.
Advantage of Functions
• Example of
creating and
invoking the
function
whatIsToday():
Functions with Parameters
• Example of invoking
the function
getSum():
Functions with Optional Parameters &
Default Values
• In creating optional
parameters — just
insert the parameter
name, followed by an
equals (=) sign,
followed by a default
value, like this.
Returning Values
• Example of
returning
multiple
values
trough an
array:
Passing Arguments to a Function by
Reference
• Example of
changing
argument
values by
reference:
Variable Scope
• Example of a
function with a
local variable
declared:
• What will be
printed?
Variable Scope
Local Variables
• Example of a
function with a
local variable
declared:
• Example of a function
with a global variable
declared:
• Text fields are one line areas that allow the user to
input text.
Forms
Text Area
•••••••
Forms
Radio Buttons