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 ...
|
|||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
|
|||
|
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? |
|
|||
|
-----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----- |
|
|||
|
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 |
|
|||
|
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? |