Jump to content

Finding number of arguments in a function.


noidtluom

Recommended Posts

Well, first off, look at the code below. It's very easy to understand:

<?php
  
  class bar
  {
    public function anothertest($foo, $bar, $baz)
    {
      echo $this->asdf;
      $num = func_num_args();
      echo $num;
    }
  }  
  
  $self = array('a', 'b', 'c', 'd');
  print_r($self);
  
  $bar = new bar();
  
  $bar->anothertest();

?>

 

Now, I want to find out how many arguments "anothertest" has before calling it. So if it has three arguments, I will do $bar->anothertest($self['0'], $self['1'], $self['2']);

 

func_num_args can only be called inside the function, so I don't think that will work.

 

How can it be done?

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.