Mega Code Archive

 
Categories / Php / Class
 

__call

<?php class A {     function getA( ) {         return array( "A", "B" );     }     function setA( $country, $district ) {         return "$country, $district\n";     } } class Helper {     private $classA;     function __construct( A $classA ) {         $this->classA = $classA;     }     function __call( $method, $args ) {         if ( method_exists( $this->classA, $method ) ) {             return call_user_func_array(array( $this->classA, $method ), $args );         }     } } $tool= new Helper( new A() ); print_r( $tool->setA( 'UK', 'BN' ) ); ?>