PicoFeed\Filter\Tag::openHtmlTag PHP Метод

openHtmlTag() публичный Метод

Return the HTML opening tag.
public openHtmlTag ( string $tag, string $attributes = '' ) : string
$tag string Tag name
$attributes string Attributes converted in html
Результат string
    public function openHtmlTag($tag, $attributes = '')
    {
        return '<' . $tag . (empty($attributes) ? '' : ' ' . $attributes) . ($this->isSelfClosingTag($tag) ? '/>' : '>');
    }

Usage Example

 public function testHtml()
 {
     $tag = new Tag();
     $this->assertEquals('<p>', $tag->openHtmlTag('p'));
     $this->assertEquals('<img src="test" alt="truc"/>', $tag->openHtmlTag('img', 'src="test" alt="truc"'));
     $this->assertEquals('<img/>', $tag->openHtmlTag('img'));
     $this->assertEquals('<br/>', $tag->openHtmlTag('br'));
     $this->assertEquals('</p>', $tag->closeHtmlTag('p'));
     $this->assertEquals('', $tag->closeHtmlTag('img'));
     $this->assertEquals('', $tag->closeHtmlTag('br'));
 }
All Usage Examples Of PicoFeed\Filter\Tag::openHtmlTag