PHP Echo HTML from class and styling

时间:2016-10-20 19:43:50

标签: php html css

I am having issues echo-ing a large amount of html from a php class and then styling it.

It seems as if unless I add breaks no CSS gets applied. Is that correct? What is the best practice?

Below is an example; there is a lot more that gets echoed then this.

$retStr = '<div class="someClass"><div class="anotherClass"><h3>Hello</h3><p class="someP">Whats up</p><img src="someLocation"/><a href="somePlace" class="someA">Hey Now</a></div></div>';
return $retStr;

VS.

$retStr = '<div class="someClass">' .PHP_EOL;
$retStr .= '<div class="anotherClass">' .PHP_EOL;
$retStr .= '<h3>Hello</h3>' .PHP_EOL;
$retStr .= '<p class="someP">Whats up</p>' .PHP_EOL;
$retStr .= '<img src="someLocation"/>' .PHP_EOL;
$retStr .= '<a href="somePlace" class="someA">Hey Now</a>' .PHP_EOL;
$retStr .= '</div>' .PHP_EOL;
$retStr .= '</div>' .PHP_EOL;
return $retStr;

Thanks!

1 个答案:

答案 0 :(得分:0)

Php echo don`t have javascript problems :)

You can store book long text in one variable and echo it without any break lines.

If you can show more code. It would be much easier to find solution to your problem.

Check if css is actualy applied on the site (use Firefox Firebug for it).