For most functions it is normal for have the function return the output of a calculation. With PHP it is also possible to pass values to the function by reference. A better way of saying this is rather than pass the value of the variable you pass a pointer to the variable itself. When you do this anything that you do to the variable inside the function is also done outside, so if you interact with the variable again it will contain a different value.
Use the following function to list the contents of one or more nested directories.
Try running the following PHP script.
The set_error_handler() function can be used in PHP to allow you to catch any run time errors and act accordingly. This function can take two parameters:
- Error Handler : This a string which is the name of the function that will be called if an error is encountered.
- Error Types (optional) : This is an optional parameter used to tell PHP on what error codes to act. This is the same error reporting setting.
The function that is defined in the function must have the following footprint as a minimum.
Appending arrays in PHP can be done with the array_merge() function. The array will take any number of arrays as arguments and will return a single array. Here is an example using just two arrays.
The following code loads the contents of a text file and randomly displays a line from it. You can use this to display a random quote on a page every time it loads.