src/Uri.php
public static function encode($value, $ignore = null)
    {
        if (null === $ignore) {
            $ignore = static::CHAR_UNRESERVED
                    . static::CHAR_GEN_DELIMS
                    . static::CHAR_SUB_DELIMS;
        }
        $rawurlencode = function (array $matches) {
            return rawurlencode($matches[0]);
        };

        return preg_replace_callback(
            '/(?:[^' . $ignore . '%]+|%(?![A-Fa-f0-9]{2}))/',
            $rawurlencode,
            $value
        );
    }
public static function encode($value, $ignore = null)
    {
        if (null === $ignore) {
            $ignore = static::CHAR_UNRESERVED
                    . static::CHAR_GEN_DELIMS
                    . static::CHAR_SUB_DELIMS;
        }
        $rawurlencode = function (array $matches) {
            return rawurlencode($matches[0]);
        };

        return preg_replace_callback(
            '/(?:[^' . $ignore . '%]+|%(?![A-Fa-f0-9]{2}))/',
            $rawurlencode,
            $value
        );
    }
public static function encode ( $ value , $ ignore = null ) { if ( null === $ ignore ) { $ ignore = static :: CHAR_UNRESERVED . static :: CHAR_GEN_DELIMS . static :: CHAR_SUB_DELIMS ; } $ rawurlencode = function ( array $ matches ) { return rawurlencode ( $ matches [ 0 ] ) ; } ; return preg_replace_callback ( '/(?:[^' . $ ignore . '%]+|%(?![A-Fa-f0-9]{2}))/' , $ rawurlencode , $ value ) ; }
URI-encode according to RFC 3986.

@param string $value  The string to be encoded
@param string $ignore Optional; service symbols by default. Characters
that will not encoded

@return string The encoded string
URI - encode according to RFC 3986 .