[thelist] PHP User Defined Functions
Andrew Embler (ML)
lists at electricstate.com
Wed Jan 2 11:35:59 CST 2002
At 07:40 AM 1/2/2002 -0800, Kristy Frey wrote:
>Is there a way to call the function w/o the include?
>
>I really appreciate the responses that everyone posts. I wish I could
>contribute more, but I only
>have about 2 months of self taught experience to share.
This came off the top of my head. I'm not sure how viable it is, but it's
something to consider:
What if you defined a function like this:
function runFunction($function_name, $arg) {
include('$some_path/$function_name ' . 'php');
$func = $function_name;
$func($arg);
}
This way, instead of:
include('foo/bar.php');
$blah = bar('x');
You get:
runFunction(bar, 'x');
Not terribly intuitive, but if you do this more than ten times in a given
file, it might be worth something.
Now, dealing with a variable amount of arguments with the functions (some
functions take two arguments, some one, some zero, etc...) could prove
challenging, but PHP.net has a section devoted to such concerns. I wish I
had more time to research it:
<http://www.php.net/manual/en/functions.arguments.php>
Anyway, hope that helps. Or at least sets you in some sort of direction.
Andrew
Andrew Embler
andrew at electricstate.com
Web Development and Design
http://www.electricstate.com
More information about the thelist
mailing list