public function xml_escape($string) {
        if (!empty($string) && htmlspecialchars($string) != $string) {
            // If the string contains something that looks like the end
            // of a CDATA section, then we need to avoid errors by splitting
            // the string between two CDATA sections.
            $string = str_replace(']]>', ']]]]><![CDATA[>', $string);
            return "<![CDATA[{$string}]]>";
        } else {
            return $string;
        }
    }
public function xml_escape($string) {
        if (!empty($string) && htmlspecialchars($string) != $string) {
            // If the string contains something that looks like the end
            // of a CDATA section, then we need to avoid errors by splitting
            // the string between two CDATA sections.
            $string = str_replace(']]>', ']]]]><![CDATA[>', $string);
            return "<![CDATA[{$string}]]>";
        } else {
            return $string;
        }
    }
public function xml_escape ( $ string ) { if ( ! empty ( $ string ) && htmlspecialchars ( $ string ) != $ string ) { // If the string contains something that looks like the end // of a CDATA section, then we need to avoid errors by splitting // the string between two CDATA sections. $ string = str_replace ( ']]>' , ']]]]><![CDATA[>' , $ string ) ; return "<![CDATA[{$string}]]>" ; } else { return $ string ; } }
Take a string, and wrap it in a CDATA secion, if that is required to make
the output XML valid.
@param string $string a string
@return string the string, wrapped in CDATA if necessary.
Take a string and wrap it in a CDATA secion if that is required to make the output XML valid .