
- Forum
- Programming Talk
- PHP
- How can define a function in a PHP?
How can define a function in a PHP?
This is a discussion on How can define a function in a PHP? within the PHP forums, part of the Programming Talk category; Today PHP is the most useful language for development but how can i define a function in PHP? If you ...
-
05-20-2011, 12:53 AM #1andrepitt77 Guest
How can define a function in a PHP?
Today PHP is the most useful language for development but how can i define a function in PHP? If you know than please reply me.
-
andrepitt77
Generally we create function.
I am not sure if you are referring to creating function or you are specifically asking about Defining a function.
We create function in PHP as shown here below
function somename($optional_arg1, $optional_arg2) {
//Do something
$result = $optional_arg1 + $optional_arg2;
return ($result);
}
PHP also has DEFINE function which is used to define a constant.
Example
define(DB_NAME,"testdb_blogs");
Once a constant is defined, it can be used anywhere.
Generally define function is used in config files from where admin can set / reset various constant values.
Regards,
Lokesh M.

Reply With Quote





