Hi guys!I have a few questions about classes,hope you guys can help me.
I have a problem right here:
Scenario:
Two classes, One of them subset of another,requires it to be called.
eg.class one

<?php 
class dataselector { 
function dataselect($blah,$blah,$blah){
/*... defines the function ...*/
}
/*some other functions*/
}
?>

eg.class two

<?php 
class crap { 
function crapselect($blah1,$blah2,$blah3){
/*... defines the function ... WHERE I NEED TO MAKE A REFERENCE TO THE FUNCTION*/
}
/*some other functions*/
}
?>

Explaination:
The first class(dataselect) is a data extraction class, which I wrote for data extraction, and i want the second class,third class(...so on) to make a reference to the first class(dataselect), the problem is, i don't know how.

thankyou for taking your time to read through and understand what I am trying to do here.

    Do you mean:

    class crap extends dataselector {
    ...
    

      You could also do:

      class myClass1
      {
        function() {}
      }
      class myClass2
      {
        function() {}
      }
      
      $class1 = new myClass1;
      $class2 = new myClass2;
      class myClass3
      {
        function()
        {
          global $class1, $class2;
          $class1->function();
          $class2->function();
         }
      }
      $class3 = new myClass3;
      class3->function();
      

      You can do it like that. but as cahva said, i think you meant extends

        If one class is logically a more specific case of another class, then it makes sense to have it extend that more general class. But if the two classes represent logically disparate objects, then you can instantiate the first class as an object within the second class:

        <?php
        class ClassA
        {
           function example()
           {
              return(1);
           }
        }
        
        class ClassB
        {
           function ClassB() // constructor
           {
              $this->a = new ClassA();
           }
           function example()
           {
              return($this->a->example());
           }
        }
        
        $test = new ClassB();
        echo $test->example();
        ?>
        
          Write a Reply...