Updating an array passed to a class

When I instantiate a class I pass it an array called $content. I call a method in the class that returns a value. I want to update the $content array in my logic module that originally called the class and then call another method in the class. If I do, the $content array is not updated in the class the second time I call a method.

I know that I can update it in the class before I return the value but is there a way to pass the initial $content variable by reference so that when it is updated by my logic module it is also updated for the class? Or is that just bad practice to let those variables “share” activity? Thanks

Why would you do that?

$content = array(“Wark”);
$class = new Class($content);
$class2 = new Class($content);
$class2->DoAThing();
So now the reference $class has… has been altered by $class2 ? What happens if i unset $content?

That’s sort of what I was thinking but wanted to validate that. Thanks for the input. Makes perfect sense.

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.