twitterfacebookgoogle plusrss feed

Pages

Tuesday, May 3, 2011

PHP Classes __call - A Magic Method


<?php
  class Greetings {
    function __call( $func, $argArr) {
      echo "Greetings, " . ucfirst($func) . " :)";
    }
  }


  $aclass = new Greetings();
  $aclass->adn();
  $aclass->john();
  $aclass->smith();
?>


The __call() Magic Method. The __call Magic method in PHP5 get called when accessing an undeclared or undefined methods of an class. With this magic method the programmer can keep track on the undeclared method which are not defined inside the class.

0 comments:

Post a Comment

comment or ask