Skip to content

Instantly share code, notes, and snippets.

@Flyingmana
Created November 3, 2010 20:15
Show Gist options
  • Save Flyingmana/661638 to your computer and use it in GitHub Desktop.
Save Flyingmana/661638 to your computer and use it in GitHub Desktop.
a relodable OnText event
<?php
return function($text){
if($text == "hello"){
//do hello world
}
if($text == "kill me"){
//took a gun and shoot =P
}
}
<?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