How to read a function definition (prototype)
Приложение R. Об этом руководстве
След.
- Each function in the manual is documented for quick reference. Knowing how
to read and understand the text will make learning PHP
much easier. Rather than relying on examples or cut/paste, you will want
to know how to read function definitions (prototypes). Let's begin:
Prerequisite: Basic understanding of types: Although PHP is a loosely typed language, it's important to have a basic understanding of types as they have important meaning.
Prerequisite: Basic understanding of types:
Although PHP is a loosely typed language, it's important to have
a basic understanding of types as
they have important meaning.
- Function definitions tell us what
type of value is returned.
Let's use the definition for strlen() as our first example:
-
strlen (PHP 3, PHP 4, PHP 5) strlen -- Get string length Description int strlen (string str) Returns the length of string.
(PHP 3, PHP 4, PHP 5)
strlen -- Get string length
Description
int strlen (string str)
Returns the length of string.
Таблица R-1. Explanation of a function definition
integer (i.e. the length of a string is measured in
numbers).
function is named str, and it's a string.
string.
- We could rewrite the above function definition in a generic way:
returned type function name (parameter type parameter name)
- Many functions take on multiple parameters, such as in_array().
Its prototype is as follows:
bool in_array (mixed needle, array haystack [, bool strict])
- What does this mean? in_array() returns a
boolean value, TRUE on
success (if the needle was found in the haystack) or FALSE on failure (if the needle was not found in the haystack). The first parameter is named needle and it can be of many different types, so we call it "mixed". This mixed needle (what we're looking for) can be either a scalar value (string, integer, or float), or an array. haystack (the array we're searching in) is the second parameter. The third optional parameter is named strict. All optional parameters are seen in [ brackets ]. The manual states that the strict parameter defaults to boolean FALSE. See the manual page on each function for details on how they work. - There are also functions with more complex PHP version information. Take html_entity_decode() as an example: - (PHP 4 >= 4.3.0, PHP 5) - This means that this function was not available in PHP 3, and is only available in a released version since PHP 4.3.0. Пред. Начало След. О заметках пользователей Уровень выше PHP versions documented in this manual 22222
haystack) or FALSE on failure (if the needle was not found in the haystack). The first parameter is named needle and it can be of many different types, so we call it "mixed". This mixed needle (what we're looking for) can be either a scalar value (string, integer, or float), or an array. haystack (the array we're searching in) is the second parameter. The third optional parameter is named strict. All optional parameters are seen in [ brackets ]. The manual states that the strict parameter defaults to boolean FALSE. See the manual page on each function for details on how they work. - There are also functions with more complex PHP version information. Take html_entity_decode() as an example: - (PHP 4 >= 4.3.0, PHP 5) - This means that this function was not available in PHP 3, and is only available in a released version since PHP 4.3.0. Пред. Начало След. О заметках пользователей Уровень выше PHP versions documented in this manual 22222
needle was not found in the haystack). The first parameter is named needle and it can be of many different types, so we call it "mixed". This mixed needle (what we're looking for) can be either a scalar value (string, integer, or float), or an array. haystack (the array we're searching in) is the second parameter. The third optional parameter is named strict. All optional parameters are seen in [ brackets ]. The manual states that the strict parameter defaults to boolean FALSE. See the manual page on each function for details on how they work. - There are also functions with more complex PHP version information. Take html_entity_decode() as an example: - (PHP 4 >= 4.3.0, PHP 5) - This means that this function was not available in PHP 3, and is only available in a released version since PHP 4.3.0. Пред. Начало След. О заметках пользователей Уровень выше PHP versions documented in this manual 22222
haystack). The first parameter is named needle and it can be of many different types, so we call it "mixed". This mixed needle (what we're looking for) can be either a scalar value (string, integer, or float), or an array. haystack (the array we're searching in) is the second parameter. The third optional parameter is named strict. All optional parameters are seen in [ brackets ]. The manual states that the strict parameter defaults to boolean FALSE. See the manual page on each function for details on how they work. - There are also functions with more complex PHP version information. Take html_entity_decode() as an example: - (PHP 4 >= 4.3.0, PHP 5) - This means that this function was not available in PHP 3, and is only available in a released version since PHP 4.3.0. Пред. Начало След. О заметках пользователей Уровень выше PHP versions documented in this manual 22222
needle and it can be of many different types, so we call it "mixed". This mixed needle (what we're looking for) can be either a scalar value (string, integer, or float), or an array. haystack (the array we're searching in) is the second parameter. The third optional parameter is named strict. All optional parameters are seen in [ brackets ]. The manual states that the strict parameter defaults to boolean FALSE. See the manual page on each function for details on how they work. - There are also functions with more complex PHP version information. Take html_entity_decode() as an example: - (PHP 4 >= 4.3.0, PHP 5) - This means that this function was not available in PHP 3, and is only available in a released version since PHP 4.3.0. Пред. Начало След. О заметках пользователей Уровень выше PHP versions documented in this manual 22222
types, so we call it
"mixed". This mixed needle (what we're looking for) can be either a scalar value (string, integer, or float), or an array. haystack (the array we're searching in) is the second parameter. The third optional parameter is named strict. All optional parameters are seen in [ brackets ]. The manual states that the strict parameter defaults to boolean FALSE. See the manual page on each function for details on how they work. - There are also functions with more complex PHP version information. Take html_entity_decode() as an example: - (PHP 4 >= 4.3.0, PHP 5) - This means that this function was not available in PHP 3, and is only available in a released version since PHP 4.3.0. Пред. Начало След. О заметках пользователей Уровень выше PHP versions documented in this manual 22222
(what we're looking for) can be either a scalar value (string, integer,
or float), or an
array.
haystack (the array we're searching in) is the second parameter. The third optional parameter is named strict. All optional parameters are seen in [ brackets ]. The manual states that the strict parameter defaults to boolean FALSE. See the manual page on each function for details on how they work. - There are also functions with more complex PHP version information. Take html_entity_decode() as an example: - (PHP 4 >= 4.3.0, PHP 5) - This means that this function was not available in PHP 3, and is only available in a released version since PHP 4.3.0. Пред. Начало След. О заметках пользователей Уровень выше PHP versions documented in this manual 22222
second parameter. The third optional parameter is
named strict. All optional parameters are seen in [ brackets ]. The manual states that the strict parameter defaults to boolean FALSE. See the manual page on each function for details on how they work. - There are also functions with more complex PHP version information. Take html_entity_decode() as an example: - (PHP 4 >= 4.3.0, PHP 5) - This means that this function was not available in PHP 3, and is only available in a released version since PHP 4.3.0. Пред. Начало След. О заметках пользователей Уровень выше PHP versions documented in this manual 22222
in [ brackets ]. The manual
states that the strict parameter defaults to boolean FALSE. See the manual page on each function for details on how they work. - There are also functions with more complex PHP version information. Take html_entity_decode() as an example: - (PHP 4 >= 4.3.0, PHP 5) - This means that this function was not available in PHP 3, and is only available in a released version since PHP 4.3.0. Пред. Начало След. О заметках пользователей Уровень выше PHP versions documented in this manual 22222
boolean FALSE. See the manual page on each function for details on
how they work.
- There are also functions with more complex PHP version information. Take
html_entity_decode() as an example:
(PHP 4 >= 4.3.0, PHP 5)
- This means that this function was not available in PHP 3, and is only
available in a released version since PHP 4.3.0.
Пред.
Начало
О заметках пользователей
Уровень выше
PHP versions documented in this manual 22222