可以这样做 - 用一个PHP标签打开一个变量,然后关闭PHP标签,但保持变量打开,以便下面的所有内容成为变量的值?或者PHP变量大小/字符是否有限制?
<?php $content = " ?>
a bunch of content goes here <br />
with lots of HTML tags and JS scripts
<?php "; ?>
Run Code Online (Sandbox Code Playgroud)
$content = <<< 'HTML'
a bunch of content goes here <br />
with lots of HTML tags and JS scripts
HTML;
Run Code Online (Sandbox Code Playgroud)
或输出缓冲,例如
<?php ob_start(); ?>
foo
<?php
$var = ob_get_clean();
var_dump($var); // will contain foo and surrounding whitespace
Run Code Online (Sandbox Code Playgroud)
不,但你可以用heredoc做一些
$content = <<< END
some content here<br/>
<script type="text/javascript">
alert('hi');
</script>
END;
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
15158 次 |
| 最近记录: |