Page 83 - Open Soource Technologies 304.indd
P. 83
Deepak Mehta, Lovely Professional University Unit 4: Functions
Unit 4: Functions Notes
CONTENTS
Objectives
Introduction
4.1 Defining a Function
4.2 Calling a Function
4.3 Variable Scope
4.3.1 Global Variables
4.3.2 Static Variables
4.4 Function Parameters
4.4.1 By-Value Parameters
4.4.2 By-Reference Parameters
4.4.3 Default Parameters
4.4.4 Variable Parameters
4.4.5 Missing Parameters
4.5 Return Values
4.6 Variable Functions
4.7 Category of PHP Functions
4.8 Summary
4.9 Keywords
4.10 Review Questions
4.11 Further Readings
Objectives
After studying this unit, you will be able to:
• Understand how to defining functions
• Understand how to call a function
• Define the variable scope
• Explain the function parameters
• Understand the variable functions
• Discuss the categories of PHP functions
Introduction
A function in PHP can be built-in or user-defined; however, they are both called the same way.
The general form of a function call is func(arg1, arg2,…). The number of arguments varies from
one function to another. Each argument is any valid expression, includes other function calls.
Here is a simple example of a predefined function:
LOVELY PROFESSIONAL UNIVERSITY 77