Re: [PHP] How to call method from another class

2002-02-03 Thread David Yee

Thanks Joel.  I thought Sandeep meant I should create object A within object
B in order to refer to the method in object A, but I guess that won't work.

David

- Original Message -
From: Joel Boonstra [EMAIL PROTECTED]
To: Sandeep Murphy [EMAIL PROTECTED]
Cc: 'David Yee' [EMAIL PROTECTED]; [EMAIL PROTECTED]
Sent: Monday, January 28, 2002 12:07 PM
Subject: RE: [PHP] How to call method from another class


  first create an instance of class B like this...
 
  $test = new classB();
 
  Now, u can refer to any function or method of classB like this:
 
  $test-hello(); // where hello() is a method of classB..

 That's not what the original question was, though.  David (I think, unless
 I got my nested replies wrong), was looking to call a method of ClassA
 with an object of ClassB:

   If I have a PHP class (let's say it's called ClassA), how do I call a
   method from another class (ClassB) within ClassA?  Thanks.

 The answer to this question, unless my OOP theory is gone, is that you
 can't, unless ClassB is an extension of classA.

 So if you have:

 class ClassA {
   // some vars
   function get_contents() {
 // some stuff
 return $something;
   }
 }

 and then:

 class ClassB extends ClassA {
   // some vars
   function display_contents() {
 print $this-get_contents();
   }
 }

 Then you're good.  Otherwise, I don't think it's possible...

 --
 [ joel boonstra | [EMAIL PROTECTED] ]




-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




[PHP] How to call method from another class

2002-01-28 Thread David Yee

If I have a PHP class (let's say it's called ClassA), how do I call a method
from another class (ClassB) within ClassA?  Thanks.

David


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




RE: [PHP] How to call method from another class

2002-01-28 Thread Sandeep Murphy


first create an instance of class B like this...

$test = new classB();

Now, u can refer to any function or method of classB like this:

$test-hello(); // where hello() is a method of classB..

cheers,
sands

-Original Message-
From: David Yee [mailto:[EMAIL PROTECTED]]
Sent: segunda-feira, 28 de Janeiro de 2002 17:19
To: [EMAIL PROTECTED]
Subject: [PHP] How to call method from another class


If I have a PHP class (let's say it's called ClassA), how do I call a method
from another class (ClassB) within ClassA?  Thanks.

David


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] How to call method from another class

2002-01-28 Thread David Yee

Got it- thanks Sandeep.

David

- Original Message -
From: Sandeep Murphy [EMAIL PROTECTED]
To: 'David Yee' [EMAIL PROTECTED]; [EMAIL PROTECTED]
Sent: Monday, January 28, 2002 11:12 AM
Subject: RE: [PHP] How to call method from another class



 first create an instance of class B like this...

 $test = new classB();

 Now, u can refer to any function or method of classB like this:

 $test-hello(); // where hello() is a method of classB..

 cheers,
 sands

 -Original Message-
 From: David Yee [mailto:[EMAIL PROTECTED]]
 Sent: segunda-feira, 28 de Janeiro de 2002 17:19
 To: [EMAIL PROTECTED]
 Subject: [PHP] How to call method from another class


 If I have a PHP class (let's say it's called ClassA), how do I call a
method
 from another class (ClassB) within ClassA?  Thanks.

 David


 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 To contact the list administrators, e-mail: [EMAIL PROTECTED]



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




RE: [PHP] How to call method from another class

2002-01-28 Thread Joel Boonstra

 first create an instance of class B like this...

 $test = new classB();

 Now, u can refer to any function or method of classB like this:

 $test-hello(); // where hello() is a method of classB..

That's not what the original question was, though.  David (I think, unless
I got my nested replies wrong), was looking to call a method of ClassA
with an object of ClassB:

  If I have a PHP class (let's say it's called ClassA), how do I call a
  method from another class (ClassB) within ClassA?  Thanks.

The answer to this question, unless my OOP theory is gone, is that you
can't, unless ClassB is an extension of classA.

So if you have:

class ClassA {
  // some vars
  function get_contents() {
// some stuff
return $something;
  }
}

and then:

class ClassB extends ClassA {
  // some vars
  function display_contents() {
print $this-get_contents();
  }
}

Then you're good.  Otherwise, I don't think it's possible...

-- 
[ joel boonstra | [EMAIL PROTECTED] ]


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]