Re: [PHP] Q on Class and EXTEND

2003-09-03 Thread Matt Matijevich
I dont know much about classes, but dont you want

$a = new THECHILD('walter'); //so you can access $a-abc

instead of

$a = new THEPARENT ('walter');

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



RE: [PHP] Q on Class and EXTEND

2003-09-03 Thread jsWalter
 -Original Message-
 From: Matt Matijevich [mailto:[EMAIL PROTECTED]
 Sent: Wednesday, September 03, 2003 11:21 AM
 To: [EMAIL PROTECTED]; [EMAIL PROTECTED]
 Subject: Re: [PHP] Q on Class and EXTEND


 I dont know much about classes, but dont you want

 $a = new THECHILD('walter'); //so you can access $a-abc

 instead of

 $a = new THEPARENT ('walter');

No, I'm wanting to EXTEND the orginal class.

meaning, my THECHILD class efines new methods/properties, and I want it used
as if it was part of the orginal THEPARENT Class.

Me just being picky.

Walter

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



Re: [PHP] Q on Class and EXTEND

2003-09-03 Thread John W. Holmes
jsWalter wrote:

-Original Message-
From: Matt Matijevich [mailto:[EMAIL PROTECTED]
I dont know much about classes, but dont you want

$a = new THECHILD('walter'); //so you can access $a-abc

instead of

$a = new THEPARENT ('walter');


No, I'm wanting to EXTEND the orginal class.

meaning, my THECHILD class efines new methods/properties, and I want it used
as if it was part of the orginal THEPARENT Class.
Me just being picky.
It doesn't work that way, exactly. The child class can define new 
methods and properties, but you must make an instance of the child 
class, which will include the methods/properties from the parent, and 
the new ones you have written.

If I'm understanding you correctly, you could rename you parent class to 
child, name the child class the same as your parent and have the old 
class extend the new class you've written. You code should then work 
the same, but have the new methods/properties available.

--
---John Holmes...
Amazon Wishlist: www.amazon.com/o/registry/3BEXC84AB3A5E/

php|architect: The Magazine for PHP Professionals  www.phparch.com

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


Re: [PHP] Q on Class and EXTEND

2003-09-03 Thread Chris Sherwood

-- snip --
  I dont know much about classes, but dont you want
 
  $a = new THECHILD('walter'); //so you can access $a-abc
 
  instead of
 
  $a = new THEPARENT ('walter');

 No, I'm wanting to EXTEND the orginal class.

 meaning, my THECHILD class efines new methods/properties, and I want it
used
 as if it was part of the orginal THEPARENT Class.

 Me just being picky.

 Walter
-- snip --

walter you want to do a declaration in the class that you want to use the
base class in ie


when you declare your child class

class Web_child extends WEB_parent
{
-- your new and extended code here
}

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



Re: [PHP] Q on Class and EXTEND

2003-09-03 Thread jsWalter
John W. Holmes [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
 jsWalter wrote:

  I'm wanting to EXTEND the orginal class.
 
  meaning, my THECHILD class efines new methods/properties, and I want it
used
  as if it was part of the orginal THEPARENT Class.
 
  Me just being picky.

 It doesn't work that way, exactly. The child class can define new
 methods and properties, but you must make an instance of the child
 class, which will include the methods/properties from the parent, and
 the new ones you have written.

 If I'm understanding you correctly, you could rename you parent class to
 child, name the child class the same as your parent and have the old
 class extend the new class you've written. You code should then work
 the same, but have the new methods/properties available.

What I am trying to do is EXTEND the PEAR::Auth Class with new properties
and methods.

But I still want to use the original instantiation call...

   $myAuth = Auth();

So, I don't think I can rename the orginal Class in this case.

I'm just being particular.

Or do I have to create my new EXTENDED Class and then add code to PEAR::Auth
to make it work as if it is always just Auth? (I was told I could not do
that)

Thanks

Walter

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



Re: [PHP] Q on Class and EXTEND

2003-09-03 Thread Chris Boget
 What I am trying to do is EXTEND the PEAR::Auth Class with new properties
 and methods.

Ok.

 But I still want to use the original instantiation call...
$myAuth = Auth();

Which is instantiating the parent class.
From what I understand of your question, you are wanting to instantiate the
parent which, in turn, somehow calls upon (or instantiats) the child simply
because the child EXTENDS the parent?  Is that correct?
If so, I don't believe this type of functionality/feature exists in any language,
much less PHP.  Am I wrong?

Chris

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



Re: [PHP] Q on Class and EXTEND

2003-09-03 Thread Raquel Rice
On Wed, 3 Sep 2003 10:05:46 -0700
Chris Sherwood [EMAIL PROTECTED] wrote:

 
 -- snip --
   I dont know much about classes, but dont you want
  
   $a = new THECHILD('walter'); //so you can access $a-abc
  
   instead of
  
   $a = new THEPARENT ('walter');
 
  No, I'm wanting to EXTEND the orginal class.
 
  meaning, my THECHILD class efines new methods/properties, and I
  want it
 used
  as if it was part of the orginal THEPARENT Class.
 
  Me just being picky.
 
  Walter
 -- snip --
 
 walter you want to do a declaration in the class that you want to
 use the base class in ie
 
 
 when you declare your child class
 
 class Web_child extends WEB_parent
 {
 -- your new and extended code here
 }
 

and then ... to access the class methods and variables of the
parent, you do it through the child.

class THEPARENT
  var $originalthis;
  function THEPARENT(){
  }
}

class THECHILD extends THEPARENT
  var $this;
  function THECHILD($that) {
$this-this = $that;
  } 
}

// outside the class
$clss = new THECHILD($thatvar);
$clss-originalthis = 'how about that';

--
Raquel

Let no man imagine that he has no influence.  Whoever he may be, and
wherever he may be placed, the man who thinks becomes a light and a
power.
  --Henry George

--
Raquel

Let no man imagine that he has no influence.  Whoever he may be, and
wherever he may be placed, the man who thinks becomes a light and a
power.
  --Henry George

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



Re: [PHP] Q on Class and EXTEND

2003-09-03 Thread CPT John W. Holmes
jsWalter wrote:

 What I am trying to do is EXTEND the PEAR::Auth Class with new properties
 and methods.

 But I still want to use the original instantiation call...

$myAuth = Auth();

 So, I don't think I can rename the orginal Class in this case.

 I'm just being particular.

 Or do I have to create my new EXTENDED Class and then add code to
PEAR::Auth
 to make it work as if it is always just Auth? (I was told I could not do
 that)


You rename the PEAR::Auth class to something like Auth2. Then, you create
your new class and call it Auth. The new Auth class will extend the old one.
Then  you include your new methods in the new class.

Your old code will still continue to work.

---John Holmes...

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