With quotes:
$new = htmlspecialchars("<a href='test'>Test</a>", ENT_QUOTES);
echo $new; // &lt;a href=&#039;test&#039;&gt;Test&lt;/a&gt;
Without quotes:
$new = htmlspecialchars("<a href='test'>Test</a>");
echo $new; // &lt;a href='test'&gt;Test&lt;/a&gt;
The second parameter possible values:
ENT_COMPAT
- Will convert double-quotes and leave single-quotes alone.
ENT_QUOTES
- Will convert both double and single quotes.
ENT_NOQUOTES
- Will leave both double and single quotes unconverted. The default is ENT_COMPAT
by Valeri Tandilashvili
4 years ago
PHP
functions
Object Oriented PHP Tutorial
1
Pro tip: use ```triple backticks around text``` to write in code fences