mercoledì 8 giugno 2011

Stringhe_1.php

<html>
<head>
<title> Gestione delle stringhe 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>

<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 "<hr>";

// Utilizzo di 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