Cannot pass parameter null by reference
Posted: Wed Aug 23, 2006 2:54 pm
I have this function:
As you can see I'd like to be able to accept an array by reference or null. But you can't do that because:
Fatal error: Cannot pass parameter 1 by reference in /osis/lib/code/php/OF/Array.php on line 48
Other than two separate parameters is there anyway you can solve this?
Code: Select all
public function setSource(&$r_source)
{
if ($r_source === null) {
switch ($_SERVER['REQUEST_METHOD']) {
case 'POST':
$this->_r_source =& $_POST;
break;
case 'GET':
$this->_r_source =& $_GET;
default:
// REQUEST_METHOD is unreliable and use POST
$this->_r_source =& $_POST;
}
} else if (is_array($r_source)) {
$this->_r_source =& $r_source;
} else {
$errMsg = 'Source must be an array or null; ' . gettype($r_source) . ' given';
throw new OF_Exception($errMsg, OF_Exception::TYPE_SCALAR);
}
}Fatal error: Cannot pass parameter 1 by reference in /osis/lib/code/php/OF/Array.php on line 48
Other than two separate parameters is there anyway you can solve this?