multiple funtions in a funtion

A

Anonymous

Guest
How can I write a function that can house multiple other funtions without specifying how many funtions I will have when I make the funtion. In other words can I have one $func var in the funtion that has two or three other funtions inside of it?

Hope that makes sense. If not I will show some code.
 
determined said:
How can I write a function that can house multiple other funtions without specifying how many funtions I will have when I make the funtion. In other words can I have one $func var in the funtion that has two or three other funtions inside of it?

Hope that makes sense. If not I will show some code.

Maybe some code would help. If you want to have one function declare other functions, just do it like so:

Code:
<?php
function func_a() {
   func_b() { /* ... */ }
   func_c() { /* ... */ }
}
?>

(Though, as a rule, this is often a bad idea and, at best, of limited benefit.)

I'm not sure what you mean by "can I have one $func var in the funtion that has two or three other funtions inside of it?" .. you can't put a function inside a variable. You can store a function declaration as a string in a variable and execute it with exec(), or you can store the name of a function in a variable and call it via the variable, but you can't store a function in a variable. Maybe if you could rephrase your question.
 
Back
Top