martedì 13 settembre 2011

STRINGA

PARTE IN HTML
<html>
<head>
<title>Gestione delle stringhe di caratteri</title>
</head>
<body>
<center>
<h2>digitare una stringa di caratteri</h2><p>
<form action="stringa_2.php" method="POST">
<input name="frase" size="100" maxlength="100"><p>
<input type="submit" value="invia">
<input type="reset" value="cancella"></center>
</form>
</body>
</html>

PARTE IN PHP
<html>
<head>
<title>Gestione delle stringhe di caratteri</title>
</head>
<body>
<?php
//inizializzazione delle variabili
$frase=$_POST['frase'];

//visualizzazione della $frase
echo $frase . "<hr>";

//visualizzazione della $frase con il for
for ($i=0;$i<strlen($frase);$i++) {
echo chr(ord(substr($frase,$i,1))+2);
}
?>
</body>
</html>