JBZoo\Utils\Str::escXml PHP Method

escXml() public static method

Escape string before save it as xml content
public static escXml ( $string ) : mixed
$string
return mixed
    public static function escXml($string)
    {
        $string = preg_replace('/[^\\x{0009}\\x{000a}\\x{000d}\\x{0020}-\\x{D7FF}\\x{E000}-\\x{FFFD}]+/u', ' ', $string);
        $string = str_replace(array("&", "<", ">", '"', "'"), array("&amp;", "&lt;", "&gt;", "&quot;", "&apos;"), $string);
        return $string;
    }

Usage Example

Exemplo n.º 1
0
 /**
  * @param $string
  * @return string
  */
 public static function xml($string)
 {
     return Str::escXml($string);
 }
All Usage Examples Of JBZoo\Utils\Str::escXml