Jump to content

Get amount of method parameters


flaab

Recommended Posts

Thanks but i'm not pretty sure if this is what i need.

 

What I need is checking how many parameters a function needs to be executed...before executing it =)

 

For example:

 

1. We want to execute function foo of class fooClass and provide an array of parameters

2. We check if the function foo of fooClass can be executed with the amount of parameters passed

3. If the array fits the number of required parameters, we execute it.

4. If not, we do not.

 

It has to be done from outside...

Thanks!

 

I've been reading it so far and I haven't figured out the way it might help me =(

 

Usually, when we execute a method without all required parameters, we get a warning message displayed in our browser, right?

 

I would like to make that an error  and do not displaying the result.

 

Example:

 

class foo {

 

      public function whatever($a, $b) { }

 

}

 

So if we try to execute foo::whatever(4,5) it works, but if i try to execute foo::whatever(4) it throws an execution error insted of a warning.

 

Maybe catching the exception like this?

 

try {

 

      foo::whatever(4);

 

} catch (Exception $e) {

 

      // Code here

 

}

 

Will that work?

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.