Jump to content

function as an argument


jimfog

Recommended Posts

I am trying to put a function as an argument of another function bit the IDE(Netbeans) highlights it as an error-I cannot understand why. Here is the code:

function output_header($admin=false,output_header_list()) { ?><div id="header">         <div><a href="http://localhost/Appointments/Administrator/"><img src="Images/logo.png" width="307" height="32" /></a></div>  </div><?php

What can be wrong here? output_header_list is the function I am trying to use as an argument.

Link to comment
Share on other sites

That syntax is invalid. You can pass the return value of a function to the function when calling it, but you can use it in the function declaration. Optional parameters have to go at the end of the parameter list. This would be valid:

// Function declarationfunction output_header($header_list, $admin=false) {  // ...}// Function calloutput_header(output_header_list(), false);

Link to comment
Share on other sites

I fixed it.

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...