Sonderzeichen kodieren/ dekodieren

Vor allem bei Get-Parametern für URLs
Beispiel ausführen
Ein einfaches Formular um schnell die entsprechende Hexadezimal-Kodierung eines speziellen Zeichens zu ermitteln, sofern man sie nicht auswendig kennt.
<?php

$pl 
'-';
$uc '-';
$plain '';
$encoded '';

if (isset(
$_POST['SEND'])){

    if( isset(
$_POST['UC']) ){
         
$pl urldecode($_POST['UC']);
        
$encoded get_magic_quotes_gpc() ?stripslashes($_POST['UC']):$_POST['UC'];
     }
    if( isset(
$_POST['PLAIN']) ){
        
$uc urlencode($_POST['PLAIN']);
                
$plain get_magic_quotes_gpc() ?stripslashes($_POST['PLAIN']):$_POST['PLAIN'];

    }
}

echo <<< EOT
<form action="{$_SERVER['PHP_SELF']}" method="post">
 <table>
  <tr>
   <th>URLENCODED</th>
   <th>PLAIN</th>
  </tr>
  <tr>
   <td><input type="text" name="UC" value="
{$encoded}"></td>
   <td><h1>
$pl</h1></td>
  </tr>
  <tr>
   <td><h1>
$uc</h1></td>
   <td><input type="text" name="PLAIN" value="
{$plain}"></td>
  </tr>
  <tr>
   <td><input type="hidden" name="SEND" value="true"><input type="submit"></td>
  </tr>
 </table>
</form>
EOT;
?>

Benutzte Funktionen


Hinweise zum DatenschutzImpressum © 2005-2008 S. Eickhoff