Ok I’ve got a unique problem. I have a function being called, and I need this to work with how it’s already being called. I’ve put together some code that shows as close as I can get to the answer:
class some_class {
private $_some_stuff = array();
public function some_method()
{
$args = func_get_args();
foreach($args as &$name)
{
$this->_some_stuff[] =& $name;
}
}
public function other_method()
{
for ($i = 0; $i < count($this->_some_stuff); $i++)
{
$this->_some_stuff[$i] = 'somevalue';
}
}
}
$some_object = new some_class();
$one = 'firstever';
$two = 'secondever';
$some_object->some_method(&$one, &$two);
$some_object->other_method(&$one, &$two);
echo $one;
echo '<br>...<br>';
echo $two;
I need $one and $two at the end to output ‘somevalue’. If it’s not clear, I need to be able to pass by reference some values into one method of an object and later have a separate method of the object still be able to access those values;
I believe that this works:
but as others have said, “how it’s already being called” is call-time pass by reference, which is deprecated