arguments

arguments

Overloading Functions In PHP

Wednesday, July 16, 2008 - 10:01

One thing that PHP doesn't allow is the creation of multiple functions with the same name. If you try this then PHP will give you a fatal error. Creating different functions with the same name is useful if you want to pass different parameters to a function that produces the same result. There are two ways around this problem.

The first is that you can pass the function an array of the items that you want. You can then use this array in the function to do whatever you want. For example.

Category: 

Using Multiple Arguments To A Function With parse_str() In PHP

Saturday, April 12, 2008 - 21:05

Sending multiple arguments to a function can be done using a parameter string. This is just like a URL that has data encoded into it. For example, if you wanted to send two parameters (called parameter1 and parameter2) to a function then you would use the following string.

parameter1=value1&parameter2=value2

To use this in the function you create the function as normal with a single parameter. This single parameter is the string that will contain all of your arguments.

Category: