I have a basic question that I was hoping someone could answer please.
In PHP, is it quicker to refer back to properties of an object over and over again, or is it faster to copy those properties into an array, if they're being used so much?
This is if you have an object already instantiated and populated fully. When you want to constantly pass some of that objects properties into various functions, should I just reuse the object, or is that in some way creating an overhead that it wouldn't in an array?
Example: I have a Request object. This object has several search parameters. I want to keep on referring to these different search parameters, so currently I'm using:
$request->d->postcode
Someone suggested copying these search parameters into an array first, then re-using the array instead:
$searchParams = get_object_vars($request->d);
then I can simply use:
$searchParams['postcode']
Many thanks for any advice.