![]() | How to read a function definition (prototype)Each function is documented for quick reference. Knowing how to read and understand the manual will make using 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:
Function definitions tell us what type of value is returned. Let's use the definition for strlen() as our first example:
Table O-1. Explanation of a function definition
We could rewrite the above function definition in a generic way:
Many functions take on multiple parameters, such as in_array(). Its prototype is as follows:
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. | ![]() | |||||||||||||