Joao Paulo
Joao Paulo

Reputation: 1103

How can i 'echo' html code in my page (PHP)?

I need to create a function that generates html code. This will output html to client for copy.

How can i do this?

For sample:

$htmlCode = "<div class='redRectangle'></div>";

If i echo $htmlCode this will show a div, but i need to show the code.

Can anyone help me?

Upvotes: 0

Views: 1037

Answers (1)

user2959229
user2959229

Reputation: 1355

Use the htmlentities function.

echo htmlentities($htmlCode);

Upvotes: 9

Related Questions