I get the follwoing error since upgrading to PHP5.3:

Warning: call_user_func_array() expects parameter 2 to be array, null given in C:\www\mysite.com\folder\page.php on line 198 

Here is the line 198:

if( call_user_func_array(array( trim($class), 'test'), NULL) )

I googled but could not figure out how to fix. Anyone🙂

    As usual, go to the doc at php.net, in this case for [man]call_user_func_array[/man] and look at the function definition

    mixed call_user_func_array ( callback $function , array $param_arr )

    and since that doesn't give enough information about what the "callback" part is supposed to be, continuing reading is a good idea, which yields this example a few lines down the page

    // Call the $foo->bar() method with 2 arguments
    $foo = new foo;
    call_user_func_array(array($foo, "bar"), array("three", "four"));

    Then compare this information with the arguments you use to call the function, and also have another look at the error message.

      johanafm;10988150 wrote:

      As usual, go to the doc at php.net...

      Thanks for the reply. I already looked at several examples but I still don't "get it".

      Php.net is the first place I go to for answers. If it's still unclear, I google. If it still does not make since I search various forums for answers, then I post a question.

      That's where I'm at... I'm just not getting it so I posted the question here.

      Below is a larger snippet, if that helps:

      function getStorageHandlers()
      	{
          $path = dirname(__FILE__).DIRECTORY_SEPARATOR.'storage';
      
      if( !($handle = opendir($path)) )
      {
        return FALSE;
      }
      
      	$storageHandlers = array();
      while( ($file = readdir($handle)) !== false )
      {
        if( !preg_match('/\.php$/i', $file) ) continue;
      
      		$name = strtolower(substr($file, 0, strrpos($file, '.')));
      		$class = 'SESessionStorage'.ucfirst($name);
      
      		if( !class_exists($class) )
        {
      			require_once(dirname(__FILE__).DIRECTORY_SEPARATOR.'storage'.DIRECTORY_SEPARATOR.$name.'.php');
      		}
      
      		if( call_user_func_array(array( trim($class), 'test'), NULL) )      {
      			$storageHandlers[] = $name;
      		}
      	}
      
      	return $storageHandlers;
        }
      
      
      
      function isNew()
      {
      	$counter = $this->get( 'session.counter' );
      return ( $counter === 1 );
      }
      
      
      
      function &get($key, $default = null, $group='default')
      {
      $group = '__' . $group;
      
      if( $this->_state !== 'active' && $this->_state !== 'expired' )
      {
        return NULL;
      }
      

        The answer is quite clear (and even included in the error message itself). PHP is expecting parameter #2 to be an array. You are not passing an array.

        (In case the solution is still not clear, here it is: pass an array.)

          bradgrafelman;10988161 wrote:

          The answer is quite clear (and even included in the error message itself). PHP is expecting parameter #2 to be an array. You are not passing an array.

          (In case the solution is still not clear, here it is: pass an array.)

          GEEZE Louise! I get that part.

          I did not write the code and I'm not a PHP programmer so I don't know how to edit that part of the code to pass and array. The samples I've found do not look enough like my code for ME to get it working. I've tried! Maybe I should have posted in the beginners forum.

          Help!!!

            If the function doesn't expect any arguments, then just pass an empty [man]array/man instead of NULL.

              bradgrafelman;10988163 wrote:

              If the function doesn't expect any arguments, then just pass an empty [man]array/man instead of NULL.

              I did not realize you could pass an empty array. Yhay worked. Thank you, very much. I really appreciate the help.

                Write a Reply...