You are here

function simple_html_dom_node::text in simplehtmldom API 5.2

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

File

simplehtmldom/simple_html_dom.php, line 205

Class

simple_html_dom_node

Code

function text() {
  if (isset($this->_[HDOM_INFO_INNER])) {
    return $this->_[HDOM_INFO_INNER];
  }
  switch ($this->nodetype) {
    case HDOM_TYPE_TEXT:
      return $this->dom
        ->restore_noise($this->_[HDOM_INFO_TEXT]);
    case HDOM_TYPE_COMMENT:
      return '';
    case HDOM_TYPE_UNKNOWN:
      return '';
  }
  if (strcasecmp($this->tag, 'script') === 0) {
    return '';
  }
  if (strcasecmp($this->tag, 'style') === 0) {
    return '';
  }
  $ret = '';
  foreach ($this->nodes as $n) {
    $ret .= $n
      ->text();
  }
  return $ret;
}