Re: String passed to object constructor turning into aninstance of that object?
| From: | Kris Deugau | Date: | Fri, 17 Dec 2010 16:50:04 +0000 |
| Subject: | Re: String passed to object constructor turning into aninstance of that object? | ||
| References: | 1 2 3 4 5 6 7 8 9 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-310105@lists.php.net to get a copy of this message | ||
David Harkness wrote:
I've never used the old-style constructors, but perhaps the semantics of
"parent::" changed and you need to instead use "$this->" as in
$this->Tag("option", $name);
That's a total guess. I don't have 5.2 handy to try it out, but both work in
5.3 using a simple example. Can you post the constructor of one of the Tag
subclasses that work? Maybe we can find a common denominator.
The most similar is Column, but all of them do very similar things - it's just the one class that seems to take a string and mutate it into what looks like an array with a string at [0] and something closely resembling what the whole object instance *should* be at [1].
class Table extends Tag {
function Table() {
parent::Tag('table');
$this->addAttribute('cellspacing', 0);
$this->addAttribute('cellpadding', 0);
$this->addAttribute('border', 0);
$this->columns = array();
$this->rows = array();
}
class Row extends Tag {
function Row($table='') {
parent::Tag('tr');
$this->table = '';
}
class Column extends Tag {
function Column($data) {
parent::Tag('td', $data);
$this->tagContent = $data;
}
class FormObject extends Tag {
function FormObject($name='') {
parent::Tag();
$this->addAttribute("name", $name);
$this->name = $name;
}
-kgd