【发布时间】:2015-02-08 11:25:09
【问题描述】:
是否可以在 php 中让第二个 div 出现在第一个 div 中,而不是让两个分开的 div 出现? 我想做一个 php dom 系统,但我被这个问题困住了。
这是我在页面返回时得到的 HTML:
<div style="width:
50px;
height:
30px;
background-color:
yellow;
color:white
">
blablabla
</div>
<div style="width:
200px;
height:
50px;
background-color:
blue;
color:white
">
</div>
这是 PHP 代码:
<? php
function genDiv($width, $height, $bgColor, $add, $content) {
echo '
<div style=\'width:
'.$width.';
height:
'.$height.';
background-color:
'.$bgColor.';
'.$add.'
\'>
'.$content.'
</div>
';
}
$block = genDiv(
'50px',
'30px',
'yellow',
'color:white',
'blablabla'
);
genDiv(
'200px',
'50px',
'blue',
'color:white',
$block
);
?>
【问题讨论】: