• Resolved shazdeh

    (@shazdeh)


    This seems like a bug with urlencode_deep function:

    print_r( urlencode_deep( array( 'width' => '80%' ) ) );

    The result of that is:

    Array
    (
        [width] => 80%25
    )

    Notice the extra 25 in the parameter.

    The why:
    I’m using add_query_arg function which in turn uses urlencode_deep function on all the parameters from the URI passed to the function. The problem is urlencode_deep function messes up one of parameters sent, so this:

    https://site.com/?width=80%

    Which is valid URL, inside the add_query_arg function becomes:

    Array
    (
        [width] => 80%25
    )

    Any idea why?

Viewing 1 replies (of 1 total)
  • Moderator bcworkz

    (@bcworkz)

    It’s just a curious coincidence, it shouldn’t affect URLs sent to browsers. The hex encoding for the percent character is %25 (0x25). urlencode() will always change any % to the hex equivalent %25. urldecode() will restore it back, you can use it on passed parameters.

Viewing 1 replies (of 1 total)
  • The topic ‘urlencode_deep function and wrong URL’ is closed to new replies.