|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2002-07-09 02:54 UTC] foobardotcom at poczta dot onet dot pl
Hello! Plase, *** excuse my english first ***
HTTP request looks like that (everything in single quotes for showing where are whitespaces - as you see, it has last newline character):
'POST /test.php HTTP/1.0
Content-Length: 13
Content-Type: application/x-www-form-urlencoded
m=1&m=2&m=3
'
Script looks like that:
<?php
header("Content-type: text/plain");
echo "got request: `" . get_request_data() . "'";
?>
and script should generate output like that:
got request: `POST /test.php HTTP/1.0
Content-Length: 13
Content-Type: application/x-www-form-urlencoded
m=1&m=2&m=3
'
I just want to make possible query-string parsing, even if POST method is used, because all people today have to use `arr[]' name in select multiple forms especially for PHP... I want to make possible PHP behave correct on select multiple even if method isn't GET (query string in GET method can be parsed manually).
I think, PHP should make access to everything low-level and make possible writting low-level based libraries for people like me - purists :)
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2026 The PHP GroupAll rights reserved. |
Last updated: Tue Jun 16 12:00:02 2026 UTC |
The problem here is not really needing to type the extra two characters, but that the resulting name/id is *not* *in* *conformance* *with* *HTML4.0*, which states that: > ID and NAME tokens must begin with a letter ([A-Za-z]) > and may be followed by any number of letters, digits > ([0-9]), hyphens ("-"), underscores ("_"), colons (":"), > and periods ("."). [http://www.w3.org/TR/html401/types.html#h-6.2] So we either have to write non-conformant HTML (not even permitted at some sites!), or program round it (e.g. by naming form elements foo_1, foo_2... and then searching for them in a loop), which is inefficient. Besides this one, bugs #10502, #15498 and #16195 are all OPEN feature requests for the "automatically convert to array" functionality, so there is a fair level of demand for it. Besides, a language that claims to be "especially suited for Web development" [http://www.php.net/] should not actually prevent the writing of standards-conformant Web pages. I wish I had the spare time to investigate the PHP sources and write a patch for this myself, but I just don't. (I only just find time to read the lists most days, but sometimes I even have to dump 100s of messages unread!) Cheers!HTTP_RAW_POST_DATA is set only when ***file*** is uploaded or somthing like that. There is no HTTP_RAW_POST_DATA if method is POST and enctype is standard - "application/x-www-form-urlencoded". I'm looking for query string (without `?' at the beginning) that is passed after HTTP request header when POST method is used. > btw: please define "behave correct on select multiple" I mean PHP should "parse" select multiple results correctly, because now it isn't, for example: GET /foo.php?bar=dot&bar=com HTTP/1.0 In PHP sciript, there's only last value: $_GET["bar"] is "com". $_GET should look as below: array( "bar" => array( 0 => "dot", 1 => "com" ) ); ...IMO of course. I tought about creating array from EVERY VARIABLE that is passed, so request: GET /foo.php?a=b HTTP/1.0 should (I say again - IMO) give $_GET array looking like that: array( "a" => array( 0 => "b" ) ); ...people who like "easy programming" will use some custom functions to make access more simple, the functions like that: function makeEasierAccessToRequestArray($arr) { foreach($arr as $key => $arrOfVals) { if (sizeof($arrOfVals) === 1) { $arr[$key] = $arrOfVals[0]; } } return $arr; } $GLOBALS["_MYGET"] = makeEasierAccessToRequestArray($_GET); Next thing: > After (...) it looks like the only suitable alternative > syntax would be > array-key- = value > or > array_key_ = value > i.e. substituting a hyphen or an underscore for the > square brackets. (...) Why PHP developers are so inclined to create MAGIC BEHAVIOURS and PHP-ONLY EXCEPTIONS (for example MAX_FILE_SIZE or arr[] multiple values)? I'm against MAGIC RULES so if someone will tell me, that he has created forms making output like this: GET /foo.php?arr[0][0]=foo&arr[0][1]=bar&arr[1][0]=dot&arr[1][1]=com HTTP/1.0 and he like to use arrays obtained from (*fucked*, being plainspoken) query-string parser from PHP, WHY HE DON'T CREATE HIS OWN LIBRARY, THAT CAN PARSE QUERY STRING AS ABOVE FOR HIS EASY USE? I see no problem: <?php function escaper($regs) { return '$GLOBALS["GET"]["' . addslashes($regs[1]) . '"] ' . $regs[2] . ' "' . addslashes($regs[3]) . '";'; } eval(preg_replace_callback("/([^=]+)(=)([^&]*)/", "escaper", $QUERY_STRING)); // it works like that: query string == "a=b", // then it evals code: $GLOBALS["GET"]["a"] = "b"; // it use escaped vals, so there's no possibility // to call function within query string or to make // parse error, for example specyfying query string // like that: `"=foo', becuase code generated then // will look like that: $GLOBALS["GET"]["\""] = "foo"; ?> Yes, and we're in the same place. WHAT WITH POST'ED VALS?! EXACTLY! If $_SERVER["SERVER_METHOD"] will be "POST" there will be no possibility to parse it manually, will the best will in the world! Why? Because there is no possibility to access HTTP-Request data RAWLY! IMHO language should be clean and logical, without ANY EXCEPTIONS AND MAGIC BEHAVIOURS. What PHP programmer will do, it's his business, not EVERYONE WHO WANT TO USE PHP. So, after my long lecture I await, there SHOULD NOT be alternative to syntax to `arr[]', because it would be MAGIC BEHAVIOUR. If someone will send request: GET /foo.php?array-key-=value&multi=1&multi=2 HTTP/1.0 $_GET should look like that: array( "array-key-" => "value", "multi" => array( 0 => "1", 1 => "2" ) ); I propose this way instead of creating every value multiple (I wrote about it before), becuase THIS LAST METHOD will not collide with every PHP-programmer habits.