php - 如何在php函数中添加div?

时间:2015-10-03 19:25:16

标签: php

我正在尝试将<div>添加到我的php中,但我在谷歌上找到的所有内容都不适用于我。我不知道我做错了什么。关于如何在PHP函数中添加<div>仅用于样式目的的任何想法?

<?php
 //get_additional is a custom function
ob_start();
echo get_additional('Cosmos','Trades');
echo nl2br("\n");
 //I want the div to start here
$buffered = ob_get_clean();
echo $buffered;
$times = $buffered;
$imgurl = 'Images/cat.png';

for($i=0;$i<$times;$i++){
echo '<img src="'.$imgurl.'" />';
}
?>

1 个答案:

答案 0 :(得分:1)

您需要echo '<img src="'.$imgurl.'" />';

就像您在代码中使用过一次<?php //get_additional is a custom function ob_start(); echo get_additional('Cosmos','Trades'); echo nl2br("\n"); //I want the div to start here echo '<div class = "blah"> // whatever you want to do here </div>'; $buffered = ob_get_clean(); echo $buffered; $imgurl = 'Images/cat.png'; for($i=0;$i<$times;$i++){ echo '<img src="'.$imgurl.'" />'; } ?>

一样

现在回到你的代码:

R = A * x + exp(x) - b