AAAAA"; But it just shows “AAAAA”...">

HTML, PHP are Escape characters '<' and '>', while echoes

I want to print the following text:

 echo "<label> AAAAA"; 

But it just shows “AAAAA” as a result.

How can I avoid '<' and '>'.

+6
source share
8 answers

Use htmlspecialchars .

 <?php echo htmlspecialchars("abc & < >"); ?> 
+16
source
 echo htmlentities("<label> AAAAA"); 
+5
source

Use htmlentities() to convert to a text string.

 <?php echo htmlentities("<label> AAAAA"); ?> 
+4
source
 <?php $string = "<label> AAAAA"; //whatever you want echo htmlspecialchars($string); ?> 

refrence htmlspecialchars

+4
source

check this http://php.net/manual/en/function.htmlentities.php and this is the code -

 echo htmlentities ("<label> AAAAA"); 
+3
source
 echo "&lt;label&gt; AAAAA"; 
0
source

Use HTML objects: &lt; for < and &gt; for > . Can be achieved using the htmlspecialchars function: http://php.net/htmlspecialchars .

Read more about HTML objects here: http://www.santagata.us/characters/CharacterEntities.html

0
source

You should avoid special characters for HTML.

echo "&lt;label&gt; AAAA"

http://www.w3schools.com/tags/ref_entities.asp

0
source

Source: https://habr.com/ru/post/915496/


All Articles