doukang7501 2017-11-23 14:35
浏览 60
已采纳

这段代码是否从类变量中调用类方法?

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?

  • 写回答

1条回答 默认 最新

  • dsjswclzh40259075 2017-11-23 14:41
    关注

    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.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 孟德尔随机化结果不一致
  • ¥15 深度学习残差模块模型
  • ¥50 怎么判断同步时序逻辑电路和异步时序逻辑电路
  • ¥15 差动电流二次谐波的含量Matlab计算
  • ¥15 Can/caned 总线错误问题,错误显示控制器要发1,结果总线检测到0
  • ¥15 C#如何调用串口数据
  • ¥15 MATLAB与单片机串口通信
  • ¥15 L76k模块的GPS的使用
  • ¥15 请帮我看一看数电项目如何设计
  • ¥23 (标签-bug|关键词-密码错误加密)