Can I place functions within functions like so:
function one() {
}
function two() {
one();
???
Your code simply uses a function from within a function, which of course is fine. How would you ever get anything done otherwise? =)
If you're thinking about declaring functions within another function, sure, also possible.
The standard for C and C++ (and even Javascript) is that functions declarations may not be nested. While you may call one function from inside another function, you may not declare a function within a function.
I did not see this defined in the PHP manual but I'd bet it's the same way. The only exception that I know of to this is Pascal.
It seems to work, but I've put all of three minutes work of effort into it, so no real answers here.
function one($var1) { function two($var2) { return $var2 * 2; } return two($var1); } print one(2);
Gives me 4. I expected errors, but...