SimplePie::__construct PHP Method

__construct() public method

To use SimplePie, create the SimplePie object with no parameters. You can then set configuration options using the provided methods. After setting them, you must initialise the feed using $feed->init(). At that point the object's methods and properties will be available to you. Previously, it was possible to pass in the feed URL along with cache options directly into the constructor. This has been removed as of 1.3 as it caused a lot of confusion.
Since: 1.0 Preview Release
public __construct ( )
    public function __construct()
    {
        if (version_compare(PHP_VERSION, '5.3', '<')) {
            trigger_error('Please upgrade to PHP 5.3 or newer.');
            die;
        }
        // Other objects, instances created here so we can set options on them
        $this->sanitize = new SimplePie_Sanitize();
        $this->registry = new SimplePie_Registry();
        if (func_num_args() > 0) {
            $level = defined('E_USER_DEPRECATED') ? E_USER_DEPRECATED : E_USER_WARNING;
            trigger_error('Passing parameters to the constructor is no longer supported. Please use set_feed_url(), set_cache_location(), and set_cache_duration() directly.', $level);
            $args = func_get_args();
            switch (count($args)) {
                case 3:
                    $this->set_cache_duration($args[2]);
                case 2:
                    $this->set_cache_location($args[1]);
                case 1:
                    $this->set_feed_url($args[0]);
                    $this->init();
            }
        }
    }

Usage Example

Ejemplo n.º 1
0
 /**
  * Setup SimplePie
  * @param array $config Array with config values. Use simplepie function names
  */
 public function __construct($config = array())
 {
     parent::__construct();
     if (!empty($config)) {
         $this->initialize($config);
     }
 }
All Usage Examples Of SimplePie::__construct