You are here

function simple_html_dom_node::outertext in simplehtmldom API 5.2

Same name and namespace in other branches
  1. 6 simplehtmldom/simple_html_dom.php \simple_html_dom_node::outertext()
  2. 7 simplehtmldom/simple_html_dom.php \simple_html_dom_node::outertext()
2 calls to simple_html_dom_node::outertext()
simple_html_dom_node::__get in simplehtmldom/simple_html_dom.php
simple_html_dom_node::__toString in simplehtmldom/simple_html_dom.php

File

simplehtmldom/simple_html_dom.php, line 177

Class

simple_html_dom_node

Code

function outertext() {
  if ($this->tag === 'root') {
    return $this
      ->innertext();
  }

  // trigger callback
  if ($this->dom->callback !== null) {
    call_user_func_array($this->dom->callback, array(
      $this,
    ));
  }
  if (isset($this->_[HDOM_INFO_OUTER])) {
    return $this->_[HDOM_INFO_OUTER];
  }
  if (isset($this->_[HDOM_INFO_TEXT])) {
    return $this->dom
      ->restore_noise($this->_[HDOM_INFO_TEXT]);
  }

  // render begin tag
  $ret = $this->dom->nodes[$this->_[HDOM_INFO_BEGIN]]
    ->makeup();

  // render inner text
  if (isset($this->_[HDOM_INFO_INNER])) {
    $ret .= $this->_[HDOM_INFO_INNER];
  }
  else {
    foreach ($this->nodes as $n) {
      $ret .= $n
        ->outertext();
    }
  }

  // render end tag
  if (isset($this->_[HDOM_INFO_END]) && $this->_[HDOM_INFO_END] != 0) {
    $ret .= '</' . $this->tag . '>';
  }
  return $ret;
}