dot in variable name

前端 未结 3 2004
梦如初夏
梦如初夏 2020-12-18 00:47

I am passing the variable with dot in query string.Php is replacing the dot with under score. So how can i retain the variable name which is having dot in the name

h

3条回答
  •  生来不讨喜
    2020-12-18 01:10

    The PHP developers implemented this in order to support register_globals() but if they'd paused for more than one second to consider the consequences then they would have only altered the names imported to the global variable namespace, not in $_POST itself. There's less than no reason for altering the request variables themselves... well, other than to make PHP incapable of handling standard form submissions.

    Here's the solution for POST variables as well, which is probably trickier for more users than the GET solution:

    function post_data(){    
       $data=explode('&',file_get_contents("php://input"));
       $post=array();
       foreach ($data as $var){
          list($key,$value)=explode('=',$var,2);
          $post[$key]=urldecode($value);
       }
       return $post; 
    }
    

提交回复
热议问题