Skip to content Skip to sidebar Skip to footer

Is It Possible To Print A Html Entity In Js Or Php?

I would like to know if it is possible to print a html entity in JavaScript or PHP. Example : console.log('7'); Whenever i try, it converts 7 into 7 instead of show

Solution 1:

You have to encode the ampersand for that to work. Try the following and see how it works:

console.log('7');

Solution 2:

A PHP solution would be -apart from simply echoing it (might be a serverside setting)- the following.

echo'1337'; //Outputs 1337 on my server.$string = '1337';
   $entities = htmlentities($string); 
   echo$entities; //Outputs 1337$decode = html_entity_decode($entities);
   echo$decode; //Outputs 1337

Post a Comment for "Is It Possible To Print A Html Entity In Js Or Php?"