public function __call($method,$p){
    if($method =="display"){
        if(is_object($p[0])){
            $this->displayObject($p[0]);
        } else if (is_array($p[0])){
            $this->displayArray($p[0]);
        } else {
            $this->displayScalar($p[0]);
        }
    }
}

class overload {

}
$ov = new overload;
$ov->display(array(1,2,3));
$ov->display('cat');

I don't know how to pass the parameters to the function and the class is empty I am beginner with php I try to learn oop

    The function needs to be inside the class (turning it into a class "method").

      class overload {
       function __call($method,$p){
          if($method =="display"){
              if(is_object($p[0])){
                  $this->displayObject($p[0]);
              } else if (is_array($p[0])){
                  $this->displayArray($p[0]);
              } else {
                  $this->displayScalar($p[0]);
              }
          }
      }
      }
      $ov = new overload;
      $ov->display(array(1,2,3));
      $ov->display('cat');

      it doesn't return any code;

      bertrc it doesn't return any code;

      Each of those display*() methods (functions) needs to be defined in the class, too.

        Write a Reply...