Re: Re: Using DOM object, how?

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

 




On Sep 19, 2005, at 3:26 PM, Vance Rodriguez wrote:
I am used to seeing global class variables initialized in the class level if they are available to the class's $this statement.

<?php
    $x = new MyDom();
    $x->createScriptElement('howdy.js');

    class MyDom
    {
        protected $dom;

        function __construct()
        {
            $this->dom         = new DOMDocument('1.0', 'iso-8859-1');
        }

        function createScriptElement($inScriptPath)
        {
            $script    = $this->dom->createElement('script','');
            $script->setAttribute('language', 'javascript');
            $script->setAttribute('src', 'howdy.js ');


            $this->dom->appendChild($script);

            echo $this->dom->saveXML();
        }
    }
?>


On Sep 19, 2005, at 3:35 PM, comex wrote:
             $dom         = new DOMDocument('1.0', 'iso-8859-1');

Shouldn't this be

$this->dom = new DOMDocument('1.0', 'iso-8859-1');

?


That didn't work either. tried a few other things as well and it looks like PHP forces you to define DOM documents in one hideous monolithic code block without any of the encapsulation benefits classes provide.

Not sure if this intentional due to security issues or if it's a bug. Anyone think of a reason why it would be necessary to prohibit DOM object embedding in a class?

Ken

--
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