/ Published in: PHP
Expand |
Embed | Plain Text
<?php class App { var $dead = true; var $output = ""; var $init = false; function errs(){ foreach($this->errs as $err){ echo "Message: $err[msg], Line: $err[line], Error Code: $err[code]"; } } private function err($msg, $line, $number) { $this->errs[] = array("msg"=>$msg, "line"=>$line, "code"=>$number); } private function kill() { $this->dead = false; } public function out($in) { if($this->dead) $this->output .= $in; } private function setOut($in, $kill=false) { if($this->dead) $this->output = $in; if($kill) $this->kill(); } function App(){ $this->init = true; $this->main(); } $this->output(); } } /* EXAMPLE USAGE: */ function init(){ $App = new App; // It will output and handle all the rest } class MyGreatAndAwesomeApp extends App { function main(){ $this->out('A'); // add to output... $this->out(' very'); // ... $this->out(' cool'); // ... $this->out(' app!'); // ... A very cool app! $this->kill(); // no more output $this->out('No ouput here'); // even here /* Also: $this->setOut('This is the only output - overrides other stuff...'); $this->setOut('Set output - then kill.', true); $this->err('Error message, ', 40, 'sdk_082'); msg line anything else $this->errs(); - output all the errors */ } } init(); ?>
You need to login to post a comment.
