dpnzf48660 2012-03-02 15:09
浏览 27
已采纳

为什么我在桌面单元格中生成的PHP会产生如此奇怪的HTML

I need some help!

Why does the following code:

function buildDeleteForm($deleteUrl,$searchArray) {
print ("<form target=\"_self\" method=\"post\">
");
print ("<input type=\"hidden\" name=\"delUrl\" value=\"" . $deleteUrl . "\" />
");
print ("<input type=\"hidden\" name=\"url\" value=\"" . $searchArray . "\" />
");
print ("<input type=\"submit\" name=\"delete\" value=\"delete\" />
</form>
");
}


foreach ($urls as $url) {
    $url = preg_replace('/\s+/', '', $url);
    print("<tr><td>" . $url . "</td>");
    $response = sendRestRequest($url,$type);
    $status = $response['http_code'];
    if ($status == 200) {
        // build the form
        print("<td class=\"result\"><img src=\"200.png\"></td><td class=\"right\">" . buildDeleteForm($url,$urllist) . "</td></tr>");
    } elseif ($status == 404) {
        print("<td class=\"result\"><img src=\"404.png\"></td><td class=\"right\">&nbsp</td></tr>");
    } else {
        print("<td class=\"result\"><img src=\"error.png\"></td><td class=\"right\">" . $status . "</td></tr>");
    }
}

Produce this crazy HTML:

<tr>
    <td>
        http://someserver4017.site.com/resources/datacaches/xi50cache/xi50cache_RetailItemCommunication_se.LUT/sv_art_40101790
    </td>
    <form target="_self" method="post">
        <input type="hidden" name="delUrl" value="http://someserver4017.site.com/resources/datacaches/xi50cache/xi50cache_RetailItemCommunication_se.LUT/sv_art_40101790" />
        <input type="hidden" name="url" value="http://someserver4017.site.com/resources/datacaches/xi50cache/xi50cache_RetailItemCommunication_se.LUT/sv_art_40101790,http://someserver4018.site.com/resources/datacaches/xi50cache/xi50cache_RetailItemCommunication_se.LUT/sv_art_40101790,http://someserver4020.site.com/resources/datacaches/xi50cache/xi50cache_RetailItemCommunication_se.LUT/sv_art_40101790" />
        <input type="submit" name="delete" value="delete" />
    </form>
    <td class="result">
        <img src="200.png">
    </td>
    <td class="right">
    </td>
</tr>

It's taken the form completely out of the table cell ... I could understand if it was just a css thing, but this is the actual generated source code being completely wierd. I know it's something simple that I just can't see and will look stupid - but hey I just want the thing to work :)

  • 写回答

3条回答 默认 最新

  • dongyi8416 2012-03-02 15:14
    关注

    Because you are evaluating the function buildDeleteForm(), which outputs a string to the user rather than simply returning it to be concatenated into the expression. Replace the multiple calls to print in buildDeleteForm() with a single return statement.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥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