Exemplo n.º 1
0
 /**
  * Create a new IE conditional comment
  *
  * @param int    $version  [description]
  * @param string $operator [description]
  * @param bool   $negate   [description]
  * @param string $content  [description]
  */
 public function __construct($version = self::DEFAULT_VERSION, $operator = self::DEFAULT_OPERATOR, $negate = false, $content = null)
 {
     parent::__construct();
     if (is_string($content) or $content instanceof \shgysk8zer0\Core_API\Interfaces\toString) {
         $this->content = "{$content}";
     } elseif ($content instanceof \DOMElement) {
         if (is_null($content->ownerDocument)) {
             (new \DOMDocument())->appendChild($content);
         }
         $this->content = $content->ownerDocument->saveHTML($content);
     }
     if (is_int($version)) {
         $this->version = $version;
     }
     if (is_bool($negate)) {
         $this->negate = $negate;
     }
     if (is_string($operator) and in_array($operator, $this->_operators)) {
         $this->operator = $operator;
     }
     $this->appendData($this->_getCondition() . $this->content);
 }
<?php

$dom = new DOMDocument('1.0', 'UTF-8');
$element = $dom->appendChild(new DOMElement('root'));
$comment = new DOMComment("This is the first comment.");
$comment->__construct("This is the second comment.");
$comment = $element->appendChild($comment);
print $dom->saveXML();