PHP vs Django argument separators
I've been re-writing a Django server in PHP (I have plenty of reasons to do this), and have run into a problem with arguments via e.g. $_REQUEST
.
Django expects arguments to be formatted as: id=822;date_accepted=2011-03-30 17:33:41;
(this is what the clients use, so this is what I want to use).
However, PHP expects arguments to be formatted as: id=822&date_accepted=2011-03-30 17:33:41;
.
So, when I read $_REQUEST in PHP, it comes o开发者_运维百科ut as: "id" => "822;date_accepted=2011-03-30 17:33:41;"
, rather than: "id" => "822", "date_accepted" => "2011-03-30 17:33:41"
.
Is there anyway to get the arguments separated correctly?
Can you try adding this to your .htaccess
file?
php_value arg_separator.input ";"
replace ; with & and run it through parse_str
$str = $_SERVER['QUERY_STRING'];//id=822;date_accepted=2011-03-30 17:33:41;
parse_str( str_replace( ';', '&', $str ), $_GET );
print_r($_GET);
精彩评论