Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- abstract class Process {
- protected $source;
- abstract function read();
- abstract function parse($type = "txt");
- protected function __construct($source) {
- $this->source = $source;
- }
- }
- class File extends Process {
- protected function __construct($source) {
- parent ::__construct($source);
- }
- public function read() {
- $fileHandle = fopen($this->source, "r");
- while (!feof($fileHandle)) {
- $line = fgets($fileHandle);
- echo $line;
- }
- fclose($fileHandle);
- }
- public function parse($type="txt") {
- switch($type) {
- case "txt" :
- // parse txt file
- break;
- case "xml" :
- // parse xml file
- break;
- }
- }
- $file = new File("file.txt", "some file resource");
- $file->read();
Add Comment
Please, Sign In to add comment