Codice PHP:
<?php
echo "<form name=\"trasforma\" method=\"post\" action=".$_SERVER['PHP_SELF'].">";
echo "dato--> ";
echo "<input type=\"text\" name=\"dato\">";
echo "
";
echo "trasformare in carattere ascii";
echo "<input type=\"radio\" value=\"carattere\" name=\"ascii\">";
echo "
";
echo "trasformare in codice ascii";
echo "<input type=\"radio\" value=\"codice\" name=\"ascii\">";
echo "
";
echo "<center><input type=\"submit\" value=\"ok\" name=\"submit\"></center>";
?>
</form>
<?php
$dato=$_POST['dato'];
if (isset($_dato))
{
if ($ascii=="carattere")
{ IF (($_dato>32)&&($_dato<=255))
{ echo $dato."-->".chr($_dato);
}
else
{ echo "ERRORE";
}
}
else
{ if (strlen($_dato)==1)
{ echo $_dato."-->".ord($_dato);
}
else
{echo "ERRORE";
}
}
}
?>
</body>
</html>