does PHP automatically run rawurldecode on any any URL to figure out what pass parameters to capture?

This is a discussion on does PHP automatically run rawurldecode on any any URL to figure out what pass parameters to capture? within the PHP Language forums, part of the PHP Programming Forums category; I noticed, to my surprise, that PHP was still able to figure that "search" is suppose to be ...


Go Back   Usenet Forums > PHP Programming Forums > PHP Language

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 01-07-2006
lawrence k
 
Posts: n/a
Default does PHP automatically run rawurldecode on any any URL to figure out what pass parameters to capture?

I noticed, to my surprise, that PHP was still able to figure that
"search" is suppose to be an array:

http://www.accumulist.com/index.php?...ds%5D=bluewall

I'm impressed with that. Till now I've used POST in my forms as the
method for doing search forms, but now I'm trying GET and everything is
working fine.

Do most browsers auto encode a form input when it is sent via a GET
method? Is the encoding standard? It does not break anywhere?

What is PHP doing that it is able to figure out that in the above URL
"search" should be an array variable in the $_GET array?

Reply With Quote
  #2 (permalink)  
Old 01-07-2006
Iván Sánchez Ortega
 
Posts: n/a
Default Re: does PHP automatically run rawurldecode on any any URL to figure out what pass parameters to capture?

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

lawrence k wrote:

> Do most browsers auto encode a form input when it is sent via a GET
> method? Is the encoding standard? It does not break anywhere?


Yes, most browsers do encode form data prior to submitting it. Yes, it is a
standard, as per RFC1738. No, it doesn't usually break.

However, you should be careful about echo()ing URLs with spaces or other
simbols in them, for example:

<?php
$escaped_term = rawurlencode($term);
echo "<a href='search.php?term=$escaped_term'>Repeat search</a>";
?>

In most other cases, you won't need to worry about URL encoding.

- --
- ----------------------------------
Iván Sánchez Ortega -i-punto-sanchez--arroba-mirame-punto-net

Un ordenador no es un televisor ni un microondas, es una herramienta
compleja.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.2 (GNU/Linux)

iD8DBQFDv6HB3jcQ2mg3Pc8RAhGRAJ0baLUwxzItmsycPRgaX6 eaOFqWTQCeIv0J
T/DIPOPuOpRLmDB2v4F+f0g=
=w86i
-----END PGP SIGNATURE-----
Reply With Quote
  #3 (permalink)  
Old 01-08-2006
Jonathan
 
Posts: n/a
Default Re: does PHP automatically run rawurldecode on any any URL to figureout what pass parameters to capture?

lawrence k wrote:
> I noticed, to my surprise, that PHP was still able to figure that
> "search" is suppose to be an array:
>
> http://www.accumulist.com/index.php?...ds%5D=bluewall
>
> I'm impressed with that. Till now I've used POST in my forms as the
> method for doing search forms, but now I'm trying GET and everything is
> working fine.


There might be a drawback if your get statements tend to get very long
(2k charachters):

http://support.microsoft.com/default...;EN-US;q208427
Reply With Quote
  #4 (permalink)  
Old 01-08-2006
lawrence k
 
Posts: n/a
Default Re: does PHP automatically run rawurldecode on any any URL to figure out what pass parameters to capture?


Iván Sánchez Ortega wrote:
> However, you should be careful about echo()ing URLs with spaces or other
> simbols in them, for example:
>
> <?php
> $escaped_term = rawurlencode($term);
> echo "<a href='search.php?term=$escaped_term'>Repeat search</a>";
> ?>
>
> In most other cases, you won't need to worry about URL encoding.


I think you mean, if I understand you right, that I need to use
rawurlencode if I'm going to use a url in an echo statement, but most
of the rest of the time, away from echo statements, I do not have to
sweat much about rawurlencoding, because browsers do so much encoding
automatically?

Reply With Quote
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT +1. The time now is 11:56 AM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0