du8980919 2016-12-06 12:25
浏览 73
已采纳

phalcon控制器中setVar和Magic setter之间的区别是什么

Reading the documentation of phalcon https://docs.phalconphp.com/en/3.0.0/reference/views.html I found that it's possible to pass variables from the controller to the view in 2 different ways:

  1. Using setVar()

    $this->view->setVar("username", $user->username);
    $this->view->setVar("posts",    $posts;
    
  2. Using the magic setter

    $this->view->username = $user->username;
    $this->view->posts    = $posts;
    

What's the difference between the two and what is the magic setter really, I couldn't find what it is.

  • 写回答

2条回答 默认 最新

      报告相同问题?

      相关推荐 更多相似问题

      悬赏问题

      • ¥15 list的ad方法出错求解答
      • ¥20 关于mmap将物理空间映射到用户空间再落盘时使用O_DIRECT方式会提示bad address的问题如何解决?
      • ¥15 无人机px4下载环境编译出错,如何解决?
      • ¥15 您好,请问您的那个pcap转成pcd文件的matlab代码我下载了运行没问题,也生成了点云图,但是无法存储pcd文件,请问怎么保存导出pcd文件呀
      • ¥260 已有标注好的图像数据集,如何构建深度卷积网络训练分类
      • ¥20 matlab图像错误
      • ¥30 如何写通过uni.uploadFile上传图片到ASP后端接收的代码
      • ¥15 selenium模糊定位
      • ¥15 硬件断点的问题,真的被整无语了
      • ¥30 想入门网络编程求建议