Reuse Code: Using Function in PHP (Part 2)Tag: Reuse Code Category:post: 12 Nov 2007 read: 496 Functions exist in most programming languages. They are used to separate code that performs a single, well defined task. This make the code easier to read and allows us to reuse the code each time we need to do the same task. (Luke Welling and Laura Thomson). PHP have built in functions which you can use for interacting with files, database, etc. But, when we build application, we need special function that not exist in built in function. Your code will probably be a mixture of existing functins combined with your own logic to perform a task for you. Basic StructureA function declaration creates or declares a new function. The declarationbegins with the keyword function, provides the function name, the parameters required, and contains the code that will be executed each time this function called:
We can call our new function with the following statement:
A few restrictions naming of your function:
We call Array_to_String() like this:
| ||
| | Give Your Opinion | Recommend |
|

