public function text($val=null)
    {
        if ($val !== null) { // set node value for all nodes
            foreach ($this->nodes as $node) {
                $node->nodeValue = $val;
            }

            return $this;
        }
        if ($node = $this->getFirstElmNode()) { // get value for first node
            return $node->nodeValue;
        }
    }
public function text($val=null)
    {
        if ($val !== null) { // set node value for all nodes
            foreach ($this->nodes as $node) {
                $node->nodeValue = $val;
            }

            return $this;
        }
        if ($node = $this->getFirstElmNode()) { // get value for first node
            return $node->nodeValue;
        }
    }
public function text ( $ val = null ) { if ( $ val !== null ) { // set node value for all nodes foreach ( $ this -> nodes as $ node ) { $ node -> nodeValue = $ val ; } return $ this ; } if ( $ node = $ this -> getFirstElmNode ( ) ) { // get value for first node return $ node -> nodeValue ; } }
Get the combined text contents of each element in the set of matched elements, including their descendants,
or set the text contents of the matched elements.

@param string|null $val

@return $this|string|null
Get the combined text contents of each element in the set of matched elements including their descendants or set the text contents of the matched elements .