Create a file named product.txt which will contain the
following records:
W1001 Hand Watch Credence
W1002 Wall Clock Samay
W1003 Alarm Clock Citizen
Create a class named Clock
which contains the following properties:
Clock_id, Clock_type and
Clock_brand.
Create a method to display
the records from text file product.txt.
<?php
class Clock {
public $data;
Public function showFile(){
$file = "product.txt";
$fh = fopen($file,'r');
while (! feof($fh) ){
$this->data .=fgets($fh). "<br>";}
return $this->data;
}
}
$clock = new Clock();
echo $clock->showFile();
?>
No comments:
Post a Comment