Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>A better solution is to use <code>rawurlencode()</code> instead of <code>urleconde()</code>.</p> <p><code>rawurlencode()</code> will convert a space to '%20' but <code>urlencode()</code> will convert a space to '+'. '%20' is what <code>decodeURIComponent()</code> is expecting for a space.</p> <p>See the following full example:</p> <pre><code>&lt;?php function xor_string( $text, $xorKey ) { $xored = ''; $chars = str_split( $text ); $i = 0; while ( $i &lt; count( $chars ) ) { $xored .= chr( ord( $chars[$i] ) ^ $xorKey ); $i++; } return $xored; } ?&gt;&lt;html&gt; &lt;body&gt; Encoded (php): &lt;div id="phpUrlEncode"&gt; &lt;?=urlencode( xor_string( 'document.location.href.search', 67 ) )?&gt; &lt;/div&gt; &lt;div id="phpRawUrlEncode"&gt; &lt;?=rawurlencode( xor_string( 'document.location.href.search', 67 ) )?&gt; &lt;/div&gt; &lt;br /&gt; Decoded (js): &lt;div id="jsDecodeUrl"&gt;&lt;/div&gt; &lt;div id="jsDecodeRawUrl"&gt;&lt;/div&gt; &lt;script type="text/javascript"&gt; function decodeStr(rawId,displayId) { var raw = document.getElementById(rawId).innerHTML; document.getElementById(displayId).innerHTML = xor_string(decodeURIComponent(raw),67); } function xor_string( str, key ) { var xored = ""; for (i=0; i&lt;str.length;i++) { var a = str.charCodeAt(i); var b = a ^ key; xored = xored+String.fromCharCode(b); } //console.log(xored); return xored; } decodeStr('phpUrlEncode','jsDecodeUrl'); decodeStr('phpRawUrlEncode','jsDecodeRawUrl'); &lt;/script&gt; &lt;/body&gt; &lt;/html&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload