Re: String passed to object constructor turning into aninstance of that object?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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

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



[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux