dongmu1951 2018-03-28 22:25
浏览 21
已采纳

如何将带有php标签的字符串放入php变量?

I want to include

action="<?php echo $_SERVER['PHP_SELF']; ?>"

in $render_form variable. But the following code does not work:

<?php $render_form = '<form method="post" action="<?php echo 
  $_SERVER['PHP_SELF']; ?>">
  <input type="text" name="name">
  <br>
  <input type="submit" name="submit" value="Submit Form">
  <br> 
  </form>'; 
?>

The following code (without php tag) works:

<?php $render_form = '<form method="post" action="">
  <input type="text" name="name">
  <br>
  <input type="submit" name="submit" value="Submit Form">
  <br>
  </form>'; 
?>
  • 写回答

1条回答 默认 最新

  • donglu8334 2018-03-28 22:29
    关注

    If I understood you, this should fit your issue

    <?php $render_form = '<form method="post" action="'. $_SERVER['PHP_SELF'] .'">
      <input type="text" name="name">
      <br>
      <input type="submit" name="submit" value="Submit Form">
      <br> 
      </form>'; 
    ?>
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥50 怎么判断同步时序逻辑电路和异步时序逻辑电路
  • ¥15 差动电流二次谐波的含量Matlab计算
  • ¥15 Can/caned 总线错误问题,错误显示控制器要发1,结果总线检测到0
  • ¥15 C#如何调用串口数据
  • ¥15 MATLAB与单片机串口通信
  • ¥15 L76k模块的GPS的使用
  • ¥15 请帮我看一看数电项目如何设计
  • ¥23 (标签-bug|关键词-密码错误加密)
  • ¥66 比特币地址如何生成taproot地址
  • ¥20 数学建模数学建模需要