Professional Documents
Culture Documents
PHP FUNCTIONS and ARRAY
PHP FUNCTIONS and ARRAY
RAJAN NEUPANE
Definition
• A function is a named block of code that does
a specific task.
• It will be executed by a call to the function.
function NameOfFunction() {
echo "my name is Rajan";
}
RAJAN NEUPANE
NameOfFunction();
Types of Functions
• There are two types of functions in PHP:
1. Internal (built-in) Functions
2. User Defined Functions
RAJAN NEUPANE
Some Internal Functions
There are more than 1000 built-in functions
phpinfo() array()
print() date()
mysqli_connect() time()
error_reporting() strlen()
error_log() copy()
RAJAN NEUPANE
PHP Arrays
• An array is a data structure that stores one or
more similar type of values in a single value.
For example if you want to store 100 numbers
then instead of defining 100 variables its easy
to define an array of 100 length.
RAJAN NEUPANE
Types of Arrays
• Numeric array − An array with a numeric index.
Values are stored and accessed in linear fashion.
RAJAN NEUPANE
Multidimensional Arrays
• $multiarray = array(
array("Ram", "Sita", "Shyam"),
array("Tulsipur", "Ghorahi", "Khaira"),
);
print_r($multiarray);
RAJAN NEUPANE