Jump to content
MakeWebGames

Url Encode


Anubis

Recommended Posts

Re: Url Encode

there isn't much to it

when you need to echo out URL links that might contain special characters, urlencode() you string

Say you wanted to pass the value: ?action=view_item&id=23&link_back=auction&link_back_action=action=view_auction

Perhaps this is a bit too complicated, but, let's view this broken up into composite parts.

?action=view_item

that is the variable that controls the switch

 

id=23

that is the item id

link_back=auction

you can match that up to an array that gives you a file name for the auction

$file_names = array('auction' => 'auction.php');

that way you're link is secure

link_back_action=action=view_auction

ah, here we have something that needs to be urlencoded

link_back_action <<<< that is the variable name

action=view_auction <<<< that is the value

but that equal sign is gonna be a pain

That value could easily be something more complex, suppose you wanted to include the auction ID (to match up the particular auction item)

action=view_auction&id=1234

so now you have a string you want to pass in the URL that you DO NOT WANT BROKEN UP INTO variable => value pairs

$link_back = urlencode('action=view_auction&id=1234');

and now the value you will pass in the URL is:

?action=view_item&id=23&link_back=auction&$link_back

And now you have a complex string with control/special characters in it that can be passed as one variable => value pair.

You don't have to urldecode that on the other end.

Any ways, there's many many uses I'm sure, but it really comes down to, are you trying to pass something in a URL that won't work?

If it's not working, try URL Encoding it

Are you trying to use something passed in a URL that won't work, try URL Decoding it. :-)

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...