Back to JsonDocument class

Method __construct

public
__construct
(mixed $options = array())
Class constructor
Parameters
  • array $options Associative array of options
Since
  • 1.7.0
Class: JsonDocument
Project: Joomla

Method __construct - Source code

/**
 * Class constructor
 *
 * @param   array  $options  Associative array of options
 *
 * @since  1.7.0
 */
public function __construct($options = array())
{
    parent::__construct($options);
    // Set mime type
    if (isset($_SERVER['HTTP_ACCEPT']) && strpos($_SERVER['HTTP_ACCEPT'], 'application/json') === false && strpos($_SERVER['HTTP_ACCEPT'], 'text/html') !== false) {
        // Internet Explorer < 10
        $this->_mime = 'text/plain';
    } else {
        $this->_mime = 'application/json';
    }
    // Set document type
    $this->_type = 'json';
}