Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

php echoing angle brackets

Tags:

php

I want to display text on the page, the text should look like this:

<sometext> ... but when I echo this, nothing appears!!

How ca I do this?

like image 548
sikas Avatar asked Nov 23 '25 09:11

sikas


1 Answers

A "page" is written in HTML, so < means "Start a tag".

You have to represent characters with special meaning in HTML using entities.

You can write them directly, or make use of the htmlspecialchars function.

echo "&lt;sometext&gt;";
echo htmlspecialchars("<sometext>");
like image 180
Quentin Avatar answered Nov 24 '25 22:11

Quentin



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!