Ask a Question related to PHP Development, Design and Development.
-
Jswalter #1
RE: [PHP] Q on Class and EXTEND
> -----Original Message-----
No, I'm wanting to EXTEND the orginal class.> From: Matt Matijevich [mailto:matijevich@alliancetechnologies.net]
> Sent: Wednesday, September 03, 2003 11:21 AM
> To: [email]php-general@lists.php.net[/email]; [email]jsWalter@torres.ws[/email]
> 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');
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
Jswalter Guest
-
#38947 [NEW]: Unable to extend mysqli class properly without causing various fatal errors
From: rk at yes-co dot nl Operating system: Debian PHP version: 5.1.6 PHP Bug Type: MySQLi related Bug description: Unable... -
Extend Date Class Flex 2 Beta 3
I want to add some methods to the Date class, like beginOfMonth / endOfMonth which returns the first millisecond and last millisecond of the month... -
Best way to extend contribute
I have an application that extends the menus and toolbars of Contribute 3.11. The only way I found how to do this is to have my installer... -
Extend the DataGrid 2
If I want to add three buttons to the datagrid then what should be the best way to go about it? Extend the DataGrid or create a composite control... -
Q on Class and EXTEND
I found a piece of code in the docs, and thought it was a way to EXTEND a Class with new properties tha cna be accessed from original Class Object.... -
John W. Holmes #2
Re: [PHP] Q on Class and EXTEND
jsWalter wrote:
It doesn't work that way, exactly. The child class can define new>>>-----Original Message-----
>>From: Matt Matijevich [mailto:matijevich@alliancetechnologies.net]
>>
>>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.
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: [url]www.amazon.com/o/registry/3BEXC84AB3A5E/[/url]
php|architect: The Magazine for PHP Professionals – [url]www.phparch.com[/url]
John W. Holmes Guest
-
Chris Sherwood #3
Re: [PHP] Q on Class and EXTEND
<-- snip -->used>> > 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<-- snip -->> as if it was part of the orginal THEPARENT Class.
>
> Me just being picky.
>
> Walter
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
}
Chris Sherwood Guest
-
Jswalter #4
Re: [PHP] Q on Class and EXTEND
"John W. Holmes" <holmes072000@charter.net> wrote in message
news:3F561CF1.3000100@charter.net...> jsWalter wrote:used> > I'm wanting to EXTEND the orginal class.
> >
> > meaning, my THECHILD class efines new methods/properties, and I want itWhat I am trying to do is EXTEND the PEAR::Auth Class with new properties>> > 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.
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
Jswalter Guest
-
Chris Boget #5
Re: [PHP] Q on Class and EXTEND
> What I am trying to do is EXTEND the PEAR::Auth Class with new properties
Ok.> and methods.
Which is instantiating the parent class.> But I still want to use the original instantiation call...
> $myAuth =& Auth();
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
Chris Boget Guest
-
Raquel Rice #6
Re: [PHP] Q on Class and EXTEND
On Wed, 3 Sep 2003 10:05:46 -0700
"Chris Sherwood" <csherwood@nortialearning.com> wrote:
and then ... to access the class methods and variables of the>
> <-- snip -->> used> >> > > 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> <-- snip -->> > as if it was part of the orginal THEPARENT Class.
> >
> > Me just being picky.
> >
> > Walter
>
> 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
> }
>
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
Raquel Rice Guest



Reply With Quote

