xml_convert()

xml_convert($str[, $protect_all = FALSE])

Parameters:
  • $str (string) – the text string to convert
  • $protect_all (bool) – Whether to protect all content that looks like a potential entity instead of just numbered entities, e.g. &foo;
Returns:

XML-converted string

Return type:

string

Takes a string as input and converts the following reserved XML characters to entities:

  • Ampersands: &
  • Less than and greater than characters: < >
  • Single and double quotes: ‘ “
  • Dashes: -

This function ignores ampersands if they are part of existing numbered character entities, e.g. &#123;. Example:

$string = '<p>Here is a paragraph & an entity (&#123;).</p>';
$string = xml_convert($string);
echo $string;

outputs:

&lt;p&gt;Here is a paragraph &amp; an entity (&#123;).&lt;/p&gt;
doc_CodeIgniter
2016-10-15 16:32:48
Comments
Leave a Comment

Please login to continue.