Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- class Cupboard
- {
- public function in($item){
- $this->items[] = $item;
- return $this;
- }
- public function out($value){
- $tmpArray = array();
- foreach($this->items as $item){
- if ($item !== $value){
- $tmpArray[] = $item;
- }
- }
- $this->items = $tmpArray;
- return $this;
- }
- public function show(){
- $itemsCurrent = '';
- foreach ($this->items as $item){
- $itemsCurrent .= $item . PHP_EOL;
- }
- return $itemsCurrent;
- }
- }
- function __autoload($name) {
- throw new Exception("Unable to load $name.");
- $path = str_replace("_", "/", $name);
- require_once $path.".php";
- }
- try {
- $obj = new NonLoadableClass();
- } catch (Exception $e) {
- echo $e->getMessage(), "\n";
- }
- $cupboard = new Cupboard;
- $value = $cupboard->in('one')
- ->in('two')
- ->out('five')
- ->show();
- echo $value;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement