PHPHtmlParser\Dom::removeSelfClosingTag PHP Method

removeSelfClosingTag() public method

Removes the tag (or tags in an array) from the list of tags that will always be self closing.
public removeSelfClosingTag ( string | array $tag )
$tag string | array
    public function removeSelfClosingTag($tag)
    {
        if (!is_array($tag)) {
            $tag = [$tag];
        }
        $this->selfClosing = array_diff($this->selfClosing, $tag);
        return $this;
    }

Usage Example

示例#1
0
 public function testLoadClosingTagRemoveSelfClosingTag()
 {
     $dom = new Dom();
     $dom->removeSelfClosingTag('br');
     $dom->load('<div class="all"><br><p>Hey bro, <a href="google.com" data-quote="\\"">click here</a></br></div>');
     $this->assertEquals('<br><p>Hey bro, <a href="google.com" data-quote="\\"">click here</a></p></br>', $dom->find('div', 0)->innerHtml);
 }