Mike S
Mike S

Reputation: 15

PHP urlencode returning unexpected results

I'm attempting to encode the following using urlencode:

 <t:RequestSecurityTokenResponse xmlns:t 

which should be encoded as:

 %3Ct%3ARequestSecurityTokenResponse+xmlns%3At 

However, the result of urlencode is this:

 %26lt%3Bt%3ARequestSecurityTokenResponse+xmlns%3At

I feel like I'm missing something extremely obvious here, but I haven't been able to figure it out. Any suggestions?

Upvotes: 0

Views: 76

Answers (1)

Symeon Quimby
Symeon Quimby

Reputation: 869

The front of your encoded string looks like the html entity for <. It appears what you are passing to urlencode has been run through htmlentities.

php > echo urlencode("<t:RequestSecurityTokenResponse xmlns:t");
%3Ct%3ARequestSecurityTokenResponse+xmlns%3At
php > echo urlencode("&lt;t:RequestSecurityTokenResponse xmlns:t");
%26lt%3Bt%3ARequestSecurityTokenResponse+xmlns%3At

Upvotes: 1

Related Questions