Created
April 10, 2015 17:57
-
-
Save scarstens/ba8cd750ca77c78740d2 to your computer and use it in GitHub Desktop.
Function to use with SimpleXML that allows you to properly encode all XML values, use in an example like $setting->addChild( $name, xml_entities($v) );
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
//for use with SimpleXML objects | |
//ie $setting->addChild( $name, xml_entities($v) ); | |
if(!function_exists('xml_entities')) { | |
function xml_entities( $string ) { | |
return strtr( | |
$string, | |
array( | |
"<" => "<", | |
">" => ">", | |
'"' => """, | |
"'" => "'", | |
"&" => "&", | |
) | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment