douyueju2912 2014-05-21 20:51
浏览 83

如何编写已经在php echo中的$ _SERVER [“PHP_SELF”]

I have a form that is written in PHP that will call the page upon itself (I don't know if I say this right).

echo('</table>
<hr>
<h1 id="loadscript_h1">Voeg een loadscript toe</h1>
<form action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]);?>" method="POST" enctype="multipart/form-data">
<div><input type="file" name="loadscript" id="loadscript" value="Kies loadscript"/></div>');
echo ('<input type="submit" class="formsubmit" name="upload_loadscript" value="Upload loadscripts" />
</form>');

But when I look at my website there is something written like this:

" method="POST" enctype="multipart/form-data">

How can I write this properly?

  • 写回答

2条回答 默认 最新

  • douxia6554 2014-05-21 20:54
    关注

    you have to use concatenation for strings. notice the '. which tells PHP to terminate string, then concatenate with the following. See the docs: http://www.php.net/manual/en/language.operators.string.php

    echo '</table>
    <hr>
    <h1 id="loadscript_h1">Voeg een loadscript toe</h1>
    <form action="'.htmlspecialchars($_SERVER["PHP_SELF"]).'" method="POST" enctype="multipart/form-data">
    <div><input type="file" name="loadscript" id="loadscript" value="Kies loadscript"/></div><input type="submit" class="formsubmit" name="upload_loadscript" value="Upload loadscripts" />
    </form>';
    

    also, you don't need parenthesis for echo.

    评论

报告相同问题?

悬赏问题

  • ¥15 keil的map文件中Image component sizes各项意思
  • ¥30 BC260Y用MQTT向阿里云发布主题消息一直错误
  • ¥20 求个正点原子stm32f407开发版的贪吃蛇游戏
  • ¥15 划分vlan后,链路不通了?
  • ¥20 求各位懂行的人,注册表能不能看到usb使用得具体信息,干了什么,传输了什么数据
  • ¥15 Vue3 大型图片数据拖动排序
  • ¥15 Centos / PETGEM
  • ¥15 划分vlan后不通了
  • ¥20 用雷电模拟器安装百达屋apk一直闪退
  • ¥15 算能科技20240506咨询(拒绝大模型回答)