Intercepting Method Calls With The __Call() Method (Php 5 Only)

<?phpfunction r( $item_array, $immediately=false ) {
  return "Registering<br />\n";
}
class Item {
  public $name = "item";
  public $price = 0;  function __call( $method, $args ) {
    $bloggsfuncs = array ( "r");
    if ( in_array( $method, $bloggsfuncs ) ) {
      array_unshift( $args, get_object_vars( $this ) );
      return call_user_func( $method, $args );
    }
  }
}$item = new Item();
print $item->r( true );
?>

Enjoyed this post? Share it!

 

Leave a comment

Your email address will not be published.