【问题标题】:Access php class method from a href从 href 访问 php 类方法
【发布时间】:2014-04-15 19:44:01
【问题描述】:

我正在尝试向开源程序添加新功能。所以文档很少,这部分是使用 smarty 用 php OOP 编写的。我会尽量保持简单。

我正在尝试复制 href 以调用类中的方法。 href 看起来像这样:

<td style="border-style:none;">
<a id="multiprintToFax" href="{$CONTROLLER}prescription&multiprintfax&id={$printm}" onclick="top.restoreSession()" class="css_button"><span>{xl t='Print'} ({xl t='Fax'})</span></a>
</td>

这是工作程序的一部分。我试图通过这样做来复制调用函数/方法:

<td>
  <a id="Re_Issue_rx" href="{$CONTROLLER}prescription&Re_Issue_rx" onclick="top.restoreSession()" class="css_button"><span>{xl t='Re-Issue'} ({xl t='Rx'})</span>
  </a>
</td>

我像这样在 Prescription 类文件中设置了一个方法

function Re_Issue_rx(){
    return 'Issued';
}

我收到一条错误消息:

  The action trying to be performed: Re_Issue_rx does not exist controller: Prescription

既然这是错误的,那么从 Prescription 类调用方法/函数的正确方法是什么?

【问题讨论】:

    标签: php class methods


    【解决方案1】:

    我的问题在发布后不久就得到了答案。

    对方法的调用应该遵循控制器设置的约定。

      Re_Issue_rx
    

    我不得不更改它以匹配命名约定。这是

     ReIssueRx_action
    

    一旦我这样做了,它就会发布“已发布”,让我知道它访问了该方法。

    谢谢!

    【讨论】:

      猜你喜欢
      • 2017-09-08
      • 2019-06-25
      • 2019-10-15
      • 2013-12-03
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多