请指导我如何在php文件中存储一串与PHP代码混合的书面html或html?
例如我想通过php文件函数添加html代码,我如何存储将在我的新html文件中显示的字符串。
答案 0 :(得分:1)
就像一个普通的字符串:
$htmlSnippet = "<div id=\"yourID\">the content of your div</div>";
或者您可以使用单引号:
$htmlSnippet = '<div id="yourID">the content of your div</div>';
答案 1 :(得分:0)
我想这就是你要找的东西。
<?php
$divId = 'main_div';
echo myfun($divId);
function myfun($divId ){
$html = "<div id='".$divId."'> This is a html div </div>";
$html .= "<input type='text' value='".$divId."'>";
return $html;
}
?>