Created
November 3, 2010 20:15
-
-
Save Flyingmana/661638 to your computer and use it in GitHub Desktop.
a relodable OnText event
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
return function($text){ | |
if($text == "hello"){ | |
//do hello world | |
} | |
if($text == "kill me"){ | |
//took a gun and shoot =P | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class OnText{ | |
private reaction; | |
public function _construct(){ | |
$this->reload(); | |
} | |
/** | |
let you use the event directly from Object | |
@example | |
$OnText = new OnText; | |
$OnText("the message"); | |
*/ | |
public function __invoke($text){ | |
return $this->reaction($text); | |
} | |
/** | |
reload the OnText event from OnText.php | |
*/ | |
public function reload(){ | |
$this->reaction = include("OnText.php"); | |
} | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment