phpclassvirtuemart

Does this code call a class method from a class variable?


I am trying to understand this line in the source of Virtuemart:

<?php
echo $product->images[0]->displayMediaThumb('class="browseProductImage" style="border-radius: 10px; border: 2px solid #8C9622"', false);
?>

It looks like a method is called by a class property (in this case an object/array $product->images[0]) and that that property is passed as a parameter to the method. But I cannot find any example of this in the PHP handbook. Can someone please explain or point me to the relevant documentation?


Solution

  • Let's break it down. $product is obviously an object. ->images[0] references a property on that object. Specifically it's the first element of a property that's an array. ->displayMediaThumb(...) is calling a method of an object. Therefore images must be an array of objects.

    "That property is passed as a parameter to the method" is incorrect. displayMediaThumb is being called for the first object within $product's $images.