Welcome to collectivesolver - Programming & Software Q&A with code examples. A website with trusted programming answers. All programs are tested and work.

Contact: aviboots(AT)netvision.net.il

Buy a domain name - Register cheap domain names from $0.99 - Namecheap

Scalable Hosting That Grows With You

Secure & Reliable Web Hosting, Free Domain, Free SSL, 1-Click WordPress Install, Expert 24/7 Support

Semrush - keyword research tool

Boost your online presence with premium web hosting and servers

Disclosure: My content contains affiliate links.

39,895 questions

51,826 answers

573 users

How to convert all applicable characters to HTML entities in PHP

3 Answers

0 votes
// string htmlentities( string $string [, int $flags = ENT_COMPAT | ENT_HTML401 
//                       [, string $encoding = ini_get("default_charset") 
//                       [, bool $double_encode = true ]]])


$s = "I'll \"write\" 'the' <b>php</b> code";

echo htmlentities($s) . "<br />\n";
echo htmlentities($s, ENT_QUOTES);

/*
run:

I'll "write" 'the' <b>php</b> code
I'll "write" 'the' <b>php</b> code


I'll &quot;write&quot; 'the' &lt;b&gt;php&lt;/b&gt; code<br />
I&#039;ll &quot;write&quot; &#039;the&#039; &lt;b&gt;php&lt;/b&gt; code

*/

 



answered Jun 28, 2016 by avibootz
0 votes
// string htmlentities( string $string [, int $flags = ENT_COMPAT | ENT_HTML401 
//                       [, string $encoding = ini_get("default_charset") 
//                       [, bool $double_encode = true ]]])


$s = "I'll \"write\" 'the' <b>php</b> code";

echo htmlentities($s, ENT_QUOTES, "UTF-8"). "<br />\n";
echo htmlentities($s, ENT_QUOTES | ENT_IGNORE, "UTF-8");

/*
run:

I'll "write" 'the' <b>php</b> code
I'll "write" 'the' <b>php</b> code


I&#039;ll &quot;write&quot; &#039;the&#039; &lt;b&gt;php&lt;/b&gt; code<br />
I&#039;ll &quot;write&quot; &#039;the&#039; &lt;b&gt;php&lt;/b&gt; code

*/

 



answered Jun 28, 2016 by avibootz
0 votes
// string htmlentities( string $string [, int $flags = ENT_COMPAT | ENT_HTML401 
//                       [, string $encoding = ini_get("default_charset") 
//                       [, bool $double_encode = true ]]])


$s = "\x8F!!";

echo htmlentities($s, ENT_QUOTES, "UTF-8"). "<br />\n";
echo htmlentities($s, ENT_QUOTES | ENT_IGNORE, "UTF-8");

/*
run:

<br />
!!

*/

 



answered Jun 28, 2016 by avibootz

Related questions

1 answer 174 views
2 answers 168 views
2 answers 208 views
4 answers 425 views
1 answer 174 views
...