Reputation: 109
I was thinking of maybe using PHP to automate some of the more tedious tasks of HTML while still generating a totally static page that doesn't require a back end. What I'm trying to do is simply print a large amount of <p></p>
tags separated by line breaks
I've glanced at this page How to echo in PHP, html tags
Here is my code
<?php
$t= "this is the text";
foreach(range(1,25) as $number) {
echo '<p>' . $t . '</p>';
echo "</br>";
}
?>
What it does prints two line breaks, one for the <p>
tags and one for the </br>
but does not actually print the <p>
tags themselves, how can I get it to print the <p>
and </p>
tags as text and then echo a line break.
Upvotes: 2
Views: 4137
Reputation: 741
USe it ,this could be work
echo "<p> helo </p> <br>";
Upvotes: 0
Reputation: 3435
Use htmlentities
to render the p
tags as text.
echo htmlentities('<p>' . $t . '</p>');
echo '<br>';
Use the PHP_EOL
constant to add a new line character the html ouput.
echo '<p>' . $t . '</p>';
echo PHP_EOL;
Upvotes: 6