Jump to content

Invalid Method Call to functionName. Requires 7, 4 given.


mkb5150

Recommended Posts

Greetings,

 

I am teaching myself and am still a beginner.  I am writing a web service which can be called by cURL or a Zend Rest Client.  The problem I'm having is that the function takes in several arguments, but some are optional.  I set default values for the optional ones, and this works great with cURL, but when I call the function from the Zend client, It tells me I have not supplied enough arguments.  Why does it not use the default values?

 

Here is my function definition:

public function functionName($a, $b, $c, $d=null, $e=null, $f=null, $g=null) { //... }

 

When I call from cURL as:

  http://localhost/program/?method=functionName&a=1&b=2&c=3&d=4

it works great.

 

But when I call from Zend as:

  $va->functionName($a, $b, $c, $d);

I get the error:

  Invalid Method Call to functionName. Requires 7, 4 given.

 

Why does it not use the default values?

 

Also, is there a way to make it so the order of the variables doesn't matter, but instead checks the NAME? with cURL, method=functionName&a=1&b=2 works the same as method=functionName&b=2&a=1 because the arguments match the name of the arguments in the function definition.  When using Zend, I would like functionName($a, $b) to work the same as functionName($b, $a) so that values get passed based on variable name, not order.  That way if the user wants to provide $a, $b, and $d, they can do so without passing an empty value for $c in the middle.

Archived

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

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.