Apertura di un file
PHP
<html>
<head>
<title>Lettura dei dati in un file di testo </title>
</head>
<body>
<center>
<h2>Elenco della classe 3C S.I.A</h2>
<?php
$fp=fopen("3csia.txt","r");
if("$fp") {
//feof=file end of file
echo"<table border='1'>"
while(!feof($fp)) {
$riga=fgets($fp,100);
$cognom="";
for( $i=0; $i<strlen($riga);$i++) {
if (substr($riga,$i,1)<> '|')
$cognom=$cognom . substr($riga,$i,1);
else $i=strlen($riga);
}
echo"<tr><td>$cognom</td><tr>. <br>";
}
fclose($fp);
}
else
echo" il file non è stato trovato.";
?>
</center>
</body>
</html>
<head>
<title>Lettura dei dati in un file di testo </title>
</head>
<body>
<center>
<h2>Elenco della classe 3C S.I.A</h2>
<?php
$fp=fopen("3csia.txt","r");
if("$fp") {
//feof=file end of file
echo"<table border='1'>"
while(!feof($fp)) {
$riga=fgets($fp,100);
$cognom="";
for( $i=0; $i<strlen($riga);$i++) {
if (substr($riga,$i,1)<> '|')
$cognom=$cognom . substr($riga,$i,1);
else $i=strlen($riga);
}
echo"<tr><td>$cognom</td><tr>. <br>";
}
fclose($fp);
}
else
echo" il file non è stato trovato.";
?>
</center>
</body>
</html>