Pagine

mercoledì 8 giugno 2011

Le stringhe di caratteri

Parte in HTML
<html>
<head>
<title> Gestione delle strinche di caratteri </title>
</head>
<body>
<center><h2>Digitare una stringa di caratteri </h2>
<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">
</form>
</center>
</body>
</html>

Parte in Php
<html>
<head>
<title> Gestione delle strinche di caratteri </title>
</head>
<body>
<?php
//Inizializzazione delle variabili
$frase=$_POST['frase'];
//Visualizzazione di $frase
echo "$frase . <hr>" ;
//Visualizzazione di $frase con il FOR
for ($i=0;$i<strlen($frase);$i++) {
echo chr(ord(substr($frase,$i,1))+2);
}
//Utilizzo di substr
echo substr($frase,5,10) . "<hr>";
//Utilizzo di strlen
echo strlen($frase) . "<hr>";
//Utilizzo di strtoupper
echo strtoupper($frase) . "<hr>";
//Utilizzo di strtolower
echo strtolower($frase) . "<hr>";
?>
</body>
</html>

Nessun commento:

Posta un commento