duanganleng0577 2015-10-05 19:17
浏览 50
已采纳

如何在动作钩子中回显PHP变量?

Here's my code:

<?php

use WHMCS\View\Menu\Item as MenuItem;

add_hook('ClientAreaPrimarySidebar', 1, function(MenuItem $primarySidebar)
{

if (!is_null($primarySidebar->getChild('Service Details Actions'))) {

  $primarySidebar->getChild('Service Details Actions')
    ->addChild('Check', array(
        'label' => 'Checker',
        'uri' => 'http://example.com/check/'.print_r($vars['params']['domain']).'-check',
        'order' => '3',
    ));
}

});

I am wanting the uri to link to here (assuming $domain = testdomain.com):

http://example.com/check/testdomain.com-check

Instead, it is showing this right now:

http://example.com/check/1-check

This is the specific line that I guess I'm having trouble with:

'uri' => 'http://example.com/check/'.print_r($vars['params']['domain']).'-check',

What am I doing wrong here?

  • 写回答

1条回答 默认 最新

  • dongningce9075 2015-10-05 19:33
    关注

    The call to print_r() is unnecessary. Assuming that the string "testdomain.com" is stored in $vars['params']['domain'], then you simply need to concatenate the variable with the string like this:

    'uri' => 'http://example.com/check/'.$vars['params']['domain'].'-check',
    

    The function print_r() prints readable information about the given variable. Typically it is only used for debugging.

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

报告相同问题?

悬赏问题

  • ¥15 安装svn网络有问题怎么办
  • ¥15 Python爬取指定微博话题下的内容,保存为txt
  • ¥15 vue2登录调用后端接口如何实现
  • ¥65 永磁型步进电机PID算法
  • ¥15 sqlite 附加(attach database)加密数据库时,返回26是什么原因呢?
  • ¥88 找成都本地经验丰富懂小程序开发的技术大咖
  • ¥15 如何处理复杂数据表格的除法运算
  • ¥15 如何用stc8h1k08的片子做485数据透传的功能?(关键词-串口)
  • ¥15 有兄弟姐妹会用word插图功能制作类似citespace的图片吗?
  • ¥15 latex怎么处理论文引理引用参考文献