regex - Get PHP to stop replacing '.' characters in $_GET or $_POST arrays? -


if pass php variables '.' in names via $_get php auto-replaces them '_' characters. example:

<?php echo "url ".$_server['request_uri']."<p>"; echo "x.y ".$_get['x.y'].".<p>"; echo "x_y ".$_get['x_y'].".<p>"; 

... outputs following:

url /spshiptool/php/testgeturl.php?x.y=a.b x.y . x_y a.b. 

... question this: there any way can stop ? cannot life of me figure out i've done deserve :-(

php version i'm running 5.2.4-2ubuntu5.3.

here's php.net's explanation of why it:

dots in incoming variable names

typically, php not alter names of variables when passed script. however, should noted dot (period, full stop) not valid character in php variable name. reason, @ it:

<?php $varname.ext;  /* invalid variable name */ ?> 

now, parser sees variable named $varname, followed string concatenation operator, followed barestring (i.e. unquoted string doesn't match known key or reserved words) 'ext'. obviously, doesn't have intended result.

for reason, important note php automatically replace dots in incoming variable names underscores.

that's http://ca.php.net/variables.external.

also, according this comment these other characters converted underscores:

the full list of field-name characters php converts _ (underscore) following (not dot):

  • chr(32) ( ) (space)
  • chr(46) (.) (dot)
  • chr(91) ([) (open square bracket)
  • chr(128) - chr(159) (various)

so looks you're stuck it, you'll have convert underscores dots in script using dawnerd's suggestion (i'd use str_replace though.)


Comments

Popular posts from this blog

Hatching array of circles in AutoCAD using c# -

ios - UITEXTFIELD InputView Uipicker not working in swift -

Python Pig Latin Translator -