returning a class of the current type
- From: yawnmoth <terra1024@xxxxxxxxx>
- Date: Mon, 26 Oct 2009 10:58:06 -0700 (PDT)
Say I have the following:
<?php
class a {
function copy()
{
return new a();
}
}
class b extends a {
function test()
{
echo 'test';
}
}
$b = new b();
$b = $b->copy();
$b->test();
That'll yield an error because $b, after calling a::copy(), is of type
a - not of type b. Would it be possible to make a::copy() return an
object not of type a but of whatever the top most class is?
.
- Follow-Ups:
- Re: returning a class of the current type
- From: Jerry Stuckle
- Re: returning a class of the current type
- From: matt
- Re: returning a class of the current type
- Prev by Date: Re: Help with IF statement behaviour
- Next by Date: Re: Downloading protected file
- Previous by thread: Call back function
- Next by thread: Re: returning a class of the current type
- Index(es):
Relevant Pages
|