public static function exportBytes($str, $all = false)
    {
        return preg_replace_callback(
            '~' . ($all ? '.' : '[^A-Za-z\d\.\{\}$<>:;\-_/\\\\=+]') . '~s',
            function ($m) use ($all) {
                if (!$all) {
                    if ($m[0] === "\r") {
                        return "\n" . '\r';
                    }

                    if ($m[0] === "\n") {
                        return '\n';
                    }
                }

                return sprintf('\x%02x', ord($m[0]));
            },
            $str
        );
    }
public static function exportBytes($str, $all = false)
    {
        return preg_replace_callback(
            '~' . ($all ? '.' : '[^A-Za-z\d\.\{\}$<>:;\-_/\\\\=+]') . '~s',
            function ($m) use ($all) {
                if (!$all) {
                    if ($m[0] === "\r") {
                        return "\n" . '\r';
                    }

                    if ($m[0] === "\n") {
                        return '\n';
                    }
                }

                return sprintf('\x%02x', ord($m[0]));
            },
            $str
        );
    }
public static function exportBytes ( $ str , $ all = false ) { return preg_replace_callback ( '~' . ( $ all ? '.' : '[^A-Za-z\d\.\{\}$<>:;\-_/\\\\=+]' ) . '~s' , function ( $ m ) use ( $ all ) { if ( ! $ all ) { if ( $ m [ 0 ] === "\r" ) { return "\n" . '\r' ; } if ( $ m [ 0 ] === "\n" ) { return '\n' ; } } return sprintf ( '\x%02x' , ord ( $ m [ 0 ] ) ) ; } , $ str ) ; }
Export binary data
@param  string $str String
@param  boolean $all Whether to replace all of chars with escaped sequences
@return string Escaped string
Export binary data