【问题标题】:Echoing PHP in HTML [duplicate]在 HTML 中回显 PHP [重复]
【发布时间】:2013-04-16 02:12:40
【问题描述】:

在 HTML <input/> 包装器和 <textarea/> 包装器内回显 PHP 有区别吗?

 <input id="element_3" name="Portnumber" class="element text medium" type="text" maxlength="255" value="<?php echo $person['portnumber']; ?>"/> 

从端口号表中回显数据。

 <textarea id="element_5" name="Description" class="element textarea medium" value="<?php echo $person['description']; ?>"></textarea> 

没有回显。

问题

文本区域包装器内的语法是否应该与输入包装器不同以显示回显。

【问题讨论】:

  • 是的,对于 textareas,内容在标签之间,而不是在 value= 属性中。还要考虑转义输出。
  • textarea 的内容应该插入到打开节点和关闭节点之间。 &lt;textarea&gt; 没有值属性
  • 使用htmlspecialchars() 正确转义变量内容。
  • 哇,我的问题有什么问题吗?哈哈
  • @bennyboy 我相信你得到了反对,因为这个问题确实表明缺乏研究。如果你用谷歌搜索这个问题,你就可以解决它而不必求助于 SO

标签: php html


【解决方案1】:

Textarea 没有 value 属性。内容被包裹在&lt;textarea&gt; 标签中:

<textarea id="element_5" name="Description" class="element textarea medium">
    <?php echo $person['description']; ?>
</textarea>

【讨论】:

  • 我喜欢似乎不需要 HTML 转义 ;-)
  • 这只是基础。可以在其他地方找到有关如何构建 php 网站的教程。
  • 对于有你代表的人,我希望得到更好的答案。
  • 非常感谢您的宝贵时间
【解决方案2】:

试试:

<textarea id="element_5" name="Description" class="element textarea medium>
<?php echo $person['description']; ?>
</textarea>

文本区域与您的常规输入不同,它们没有value 属性

【讨论】:

    【解决方案3】:

    Textarea 没有值属性

     <textarea id="element_5" name="Description" class="element textarea medium"><?php echo $person['description']; ?></textarea> 
    

    【讨论】:

      猜你喜欢
      • 2012-01-02
      • 2016-02-10
      • 1970-01-01
      • 2011-06-30
      • 1970-01-01
      • 1970-01-01
      • 2013-11-30
      • 1970-01-01
      相关资源
      最近更新 更多