du131642 2012-09-20 04:55
浏览 18
已采纳

symfony2中不寻常的Php语法

I saw an interesting syntax in symfony 2.x and i am not sure how to call it and what type of variable it is.

In the view, There is a helper variable called $view and it can be used in for many things and here is what i don't understand

Sometimes it is used like an array:

$view['action']->someMethod();

and other times it is used as an object

$view->generateUrl(...);

Both in the same file. Dumping variables using var_dump() in symfony is not a very good idea .

So What kind of object is this, and how can I create it.

  • 写回答

1条回答 默认 最新

  • dongwen3437 2012-09-21 22:57
    关注

    With ArrayAccess you can access to the object as array with associative keys

    http://php.net/manual/en/class.arrayaccess.php

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

报告相同问题?

悬赏问题

  • ¥15 用C语言实现语音的读取及播放
  • ¥15 poi怎么在指定位置之后生成多个表格
  • ¥15 nginx在location设置了client_max_body_size依旧报错413
  • ¥15 C#添加WCF服务引用客户端调用方法没有反应
  • ¥15 stm32f103c8t6与esp8266
  • ¥15 使用Hadoop的MapReduce program
  • ¥15 Python发生IndexError错误如何解决?
  • ¥15 如何用matlab搭建激光器
  • ¥15 51单片机两路互补SPWM输出全桥逆变
  • ¥15 outlook左边用户名下拉为啥打不开了