mercoledì 8 giugno 2011

stringa_1.php

<html>
<head>
<title>Gestione delle stringhe di caratteri</title>
</head>
<body>
<h2><center>Digitare una stringa di caratteri</center></h2>
<form action="stringa_2.php" method="POST">
<input name="frase" size="100" maxlenght="100"><p>
<input type="submit" value="Invia">
<input type="reset" value="Cancella">
</form>
</center>
</body>
</html>


stringa_2.php



<html>
<head>
<title>Gestione delle stringhe 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);
echo "<p>";
// Utilizzo si strlen
echo strlen($frase);
echo "<hr>";
//Utilizzo di strtoupper
echo strtoupper($frase);
echo "<hr>";
//Utilizzo di strtolower
echo strtolower($frase);
echo "<hr>";

?>
</body>
</html>

Nessun commento:

Posta un commento