Declaring a Function PHP

When you declare a function, you start with the function statement. Next comes a name for your function. Inside the parentheses is a list of arguments separated by commas. You may choose to have no arguments. shows you the form of a function declaration.

Declaring a function.

Declaring a function.
In other languages, including older versions of PHP, you must declare a function above any call to it. This is not true of PHP 4. You may put a function declaration after calls made to it. When you call a function, you write its name followed by parentheses, even if there are no arguments to pass.

Functions allow you to put together a block of code that you will repeat several times throughout your script. Your motivation may be to avoid typing identical code in two or more places, or it could be to make your code easier to understand. Consider It declares a function called printBold that prints any text with bold tags around it.


All rights reserved © 2018 Wisdom IT Services India Pvt. Ltd Protection Status

PHP Topics