duanboshi1472 2014-05-20 15:54
浏览 73
已采纳

在按钮的value参数内插入自定义字符串

Hello I am trying to insert custom string inside button Value, but I am facing a problem when I inster the string inside the value parameter the string is appering like text instead as a valuer="" inside the button string. Here is my button code:

$buttons = '<input type="submit" name="Submit" style="width:110px;margin:0 auto;display:block;"  value="'.pll_e('message','wpnotification').'" />' ;

So basicaly I need when this is rendered the result of the function to be shown inside the input button not outside

Instead of the result of this to be <input type="submit" name="Submit" style="width:110px;margin:0 auto;display:block;" value="String Text">

The result is:

String Text
<input type="submit" name="Submit" style="width:110px;margin:0 auto;display:block;"  value="">

So I need this text to apper inside the value tag.

  • 写回答

1条回答 默认 最新

  • dousuo8400 2014-05-20 16:12
    关注

    Converting my comment into answer...

    I think i know what the problem is. pll_e() function must be echoing the output instead of returning it.

    Your function must look something similar to this:

    function pll_e($paramA, $paramB) {
        echo $paramA . " " . $paramB;
    }
    

    If that's the case, then you can deal with it by capturing the output buffer to a variable and use it on the button like this:

    ob_start();
    pll_e('message','wpnotification');
    $funcValue = ob_get_clean();
    
    $buttons = '<input type="submit" name="Submit" style="width:110px;margin:0 auto;display:block;"  value="'. $funcValue .'" />';
    

    Alternatively, if you have access to the pll_e function... then just change it, so it return the value instead of echo it like this (example):

    function pll_e($paramA, $paramB) {
        return $paramA . " " . $paramB;
    }
    
    $buttons = '<input type="submit" name="Submit" style="width:110px;margin:0 auto;display:block;"  value="'. pll_e('message','wpnotification') .'" />' ;
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 如何在scanpy上做差异基因和通路富集?
  • ¥20 关于#硬件工程#的问题,请各位专家解答!
  • ¥15 关于#matlab#的问题:期望的系统闭环传递函数为G(s)=wn^2/s^2+2¢wn+wn^2阻尼系数¢=0.707,使系统具有较小的超调量
  • ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
  • ¥30 截图中的mathematics程序转换成matlab
  • ¥15 动力学代码报错,维度不匹配
  • ¥15 Power query添加列问题
  • ¥50 Kubernetes&Fission&Eleasticsearch
  • ¥15 報錯:Person is not mapped,如何解決?
  • ¥15 c++头文件不能识别CDialog