Php EOD解析内容
我试图在文本区域中回显布局文件,以便可以从联机界面编辑布局,但问题是,即使在PHP中的heredoc中,它仍在解析布局。这是我必须输出EOD的代码Php EOD解析内容,php,Php,我试图在文本区域中回显布局文件,以便可以从联机界面编辑布局,但问题是,即使在PHP中的heredoc中,它仍在解析布局。这是我必须输出EOD的代码 echo ( <<<EOD <div class="shadowbar"> <form method="post" action="index.php?action=acp&mode=layout"> <fieldset> <legen
echo (
<<<EOD
<div class="shadowbar">
<form method="post" action="index.php?action=acp&mode=layout">
<fieldset>
<legend>Advanced Layout Editor</legend>
<div class="input-group">
<textarea rows="8" placeholder="Layout File" name="layout" id="about" cols="100" value="$layoutFile"></textarea><br />
</div>
</fieldset>
<input class="Link LButton" type="submit" value="Submit Edits" name="submit" />
</form>
</div>
EOD
);
echo(
没有值
属性。正确的语法是
echo <<<EOD
<textarea>$your_content_here</textarea>
EOD;
将为HTML生成以下内容:
<textarea><textarea>foo</textarea>Please fill in the text box</textarea>
a b c d
foo请填写文本框
a、b、c、d
您无法嵌套文本区域,因此标记B将被忽略,标记C(来自“要编辑的文本”)将终止A标记,标记D将是一个悬空/非法的额外结束标记。现在,您的可编辑文本已从表单中泄漏,不再是要编辑的文本的一部分。括号只是因为如果没有它们,我的IDE将无法识别Heredoc Nowdoc,并且它不会改变脚本的运行方式。此外,我已经尝试过了(我想我在问题中提到了这一点)它不起作用。同样,如果你在那里发布html,它将被浏览器解析。你必须通过htmlspecialchars()
运行它以“取消html”它。@MarcB如果你编辑你的答案来包含它,我可以接受,因为它起作用了。编辑:我完全忘记了我可以使用这个函数,当你提到它时,我认为它完全删除了标记。我查看了php文档,发现这正是我需要的。谢谢。
<textarea><textarea>foo</textarea>Please fill in the text box</textarea>
a b c d