parameter passing - PHP - urlencoded() ampersand in url perceived as actual ampersand -
there dummy example php application shows causes me problems.
<?php echo ((isset($_get['p'])) ? print_r($_get) : "<a href='http://example.com/a.php?p=" . urlencode('one & two') . "'>one & two</a>"); ?>
if visit page without p parameter page output:
http://example.com/one+%26+two
, that's fine, if visit link, script return:
array ( [p] => 1 [two] => )
and that's wrong.
in real application, in url submitted 30 char long alphanumeric string contains special letters(swedish).
edit: in real application use url rewrite:
<ifmodule mod_rewrite.c> rewriteengine on rewriterule ^(.*)$ ../example.php?s=$1 [l,qsa] </ifmodule>
can cause? - confirmed. issue. see answer below.
you need send url using %
escape ampersand. try 'one %26 two'
<?php echo ((isset($_get['p'])) ? print_r($_get) : "<a href='http://example.com/a.php?p=one %26 two'>one & two</a>"); ?>
Comments
Post a Comment