src/Core/Convert.php
public static function raw2js($val)
    {
        if (is_array($val)) {
            foreach ($val as $k => $v) {
                $val[$k] = self::raw2js($v);
            }
            return $val;
        }

        return str_replace(
            // Intercepts some characters such as <, >, and & which can interfere
            array("\\", '"', "\n", "\r", "'", '<', '>', '&'),
            array("\\\\", '\"', '\n', '\r', "\\'", "\\x3c", "\\x3e", "\\x26"),
            $val
        );
    }
public static function raw2js($val)
    {
        if (is_array($val)) {
            foreach ($val as $k => $v) {
                $val[$k] = self::raw2js($v);
            }
            return $val;
        }

        return str_replace(
            // Intercepts some characters such as <, >, and & which can interfere
            array("\\", '"', "\n", "\r", "'", '<', '>', '&'),
            array("\\\\", '\"', '\n', '\r', "\\'", "\\x3c", "\\x3e", "\\x26"),
            $val
        );
    }
public static function raw2js ( $ val ) { if ( is_array ( $ val ) ) { foreach ( $ val as $ k => $ v ) { $ val [ $ k ] = self :: raw2js ( $ v ) ; } return $ val ; } return str_replace ( // Intercepts some characters such as <, >, and & which can interfere array ( "\\" , '"' , "\n" , "\r" , "'" , '<' , '>' , '&' ) , array ( "\\\\" , '\"' , '\n' , '\r' , "\\'" , "\\x3c" , "\\x3e" , "\\x26" ) , $ val ) ; }
Ensure that text is properly escaped for Javascript.

@param array|string $val String to escape, or array of strings
@return array|string
Ensure that text is properly escaped for Javascript .