Jump to content

calling a function within a function


jimfog

Recommended Posts

when output_header gets called, don;t we also call the inner function function(username) (by setting its value to false)
No.The very idea of the "if" is to prevent exactly THAT scenario.When output_header gets called, it checks if it can call the inner function, and calls it only if it can. A boolean false does not translate to a function that can be called, so no function is ever called within output_headers in that case.
Link to comment
Share on other sites

No. The very idea of the "if" is to prevent exactly THAT scenario. When output_header gets called, it checks if it can call the inner function, and calls it only if it can. A boolean false does not translate to a function that can be called, so no function is ever called within output_headers in that case.
The thing that confused my is that the Is_callable had as an argument $function.We can use anything there provided that it is something that cannot be called. I used this for example:
if (is_callable('tel')) {    $function($username);

and it still did the job.

Link to comment
Share on other sites

No. A boolean false does not translate to a function that can be called, so no function is ever called within output_headers in that case.
The above phrase though, completes the puzzle-at least for now.
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...