如何获取simple_html_dom';s函数在类中使用


How to get instances of simple_html_dom's function to use in a class

我有一个类ClassA,并且希望在这个类中使用simple_html_dom的函数。我该怎么做?这是simple_html_dom类的链接http://www.megafileupload.com/en/file/366382/simple-html-dom-rar.html

<?php
    Class A
    {
        private $simpleHTML;
        function __construct()
        {
            $this->simpleHTML = new simple_html_dom(); 
            //now you can call all simple html functions using $this->simpleHTML->..
        }
        //define file_get_html as a class method. You can call this as 
        // $x = new A();
        //$x->file_get_html..(externally) or $this->file_get_html(.. (internally)
        function file_get_html($url, 
                        $use_include_path = false, 
                        $context=null, $offset = -1, 
                        $maxLen=-1, $lowercase = true, 
                        $forceTagsClosed=true, 
                        $target_charset = DEFAULT_TARGET_CHARSET, 
                        $stripRN=true, 
                        $defaultBRText=DEFAULT_BR_TEXT)
        {
            // We DO force the tags to be terminated.
            $dom = new simple_html_dom(null, $lowercase, $forceTagsClosed, $target_charset, $defaultBRText);
            // For sourceforge users: uncomment the next line and comment the retreive_url_contents line 2 lines down if it is not already done.
            $contents = file_get_contents($url, $use_include_path, $context, $offset);
            // Paperg - use our own mechanism for getting the contents as we want to control the timeout.
            //$contents = retrieve_url_contents($url);
            if (empty($contents))
            {
                return false;
            }
            // The second parameter can force the selectors to all be lowercase.
            $dom->load($contents, $lowercase, $stripRN);
            return $dom;
        }
    }
?>