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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...