Camrin Parnell
Camrin Parnell

Reputation: 449

Passing an object reference to a function

I am tryingto pass the reference of a object to a php function , can anyone show me an example. I did look on google, for about an hour but could not find completely what I was looking for.

Thanks

Upvotes: 1

Views: 659

Answers (1)

halfdan
halfdan

Reputation: 34254

Objects are always passed by reference in PHP:

$a = new Class();
$b = new OtherClass();
$a->setB($b);

This will pass $b as reference to $a->setB()

Upvotes: 4

Related Questions