
12.06.2008, 22:24
|
|
Участник форума
Регистрация: 11.05.2008
Сообщений: 202
Провел на форуме: 420713
Репутация:
104
|
|
Почему не раб счетчик
Почему не раб счетчик
PHP код:
<?php
class file
{
var $file;
var $bufer;
function __construct($files)
{
//open file from directory
$this->file=fopen($files,"r+");
if(!$this->file)
{
echo "Error open file";
}
}
function bufer ()
{
// here view
$this->bufer =fread($this->file,100);
}
function prints()
{
echo $this->bufer;
echo "<br>";
}
function __destruct()
{
fclose($this->file);
}
}
class file2 extends file
{
function write($text)
{
fputs($this->file,$text);
}
function counts()
{
$total = 0;
while(!feof($this->file))
{
$str = fgets($this->file);
$total++;
}
echo $total;
}
}
$one = new file2 ("file.txt");
$one->bufer();
$one->prints();
echo"<br>";
$one->counts();
echo"<br>";
$text="best PHP";
$one->write($text);
?>
|
|
|