PHP 打印和回显 HTML
很简单的问题。哈哈,我不好意思问这个问题,因为我通常对 php 非常擅长,但是在 php 中显示 html 的方法有哪些?例如:
<? if($flag): ?>
<div>This will show is $flag is true </div>
<? endif; ?>
或者
<?
if($flag)
echo '<div>This will show is $flag is true </div>';
?>
我知道至少还有其他两种方式我就是记不住它们... 帮助是肯定的。提前赞赏! =D
very simple question. Lol i am embarassed to ask this cause i am usually very good with php but what are the ways to display html inside of php? for example:
<? if($flag): ?>
<div>This will show is $flag is true </div>
<? endif; ?>
OR
<?
if($flag)
echo '<div>This will show is $flag is true </div>';
?>
I know that there are at least 2 other ways i just cannot remember them atm...
Help is def. appreciated in advance!! =D
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
以下是 heredoc 可以使用:
如果你不想变量插值,你必须像我上面那样转义可能的变量名。或者,您可以使用 nowdoc PHP 5.3 及以上版本:
Here's how a heredoc could be used:
If you don't want variable interpolation, you have to escape possible varnames as I have above. Alternatively, you can use a nowdoc with PHP 5.3 onwards:
您还可以使用 heredoc< /a>.
You can also use a heredoc.
PHP 还有一个 nowdoc 语法的工作方式类似于 heredoc,但与单引号字符串类似,这些文档块不会被解析。
PHP also has a nowdoc syntax that works like heredoc, but similar to single quoted strings, these doc blocks do not get parsed.