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

Popular posts from this blog

javascript - gulp-nodemon - nodejs restart after file change - Error: listen EADDRINUSE events.js:85 -

Fatal Python error: Py_Initialize: unable to load the file system codec. ImportError: No module named 'encodings' -

oracle - Changing start date for system jobs related to automatic statistics collections in 11g -