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 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'));
 }
Пример #2
0
 /**
  * Parse opening tag.
  *
  * @param resource $parser     XML parser
  * @param string   $tag        Tag name
  * @param array    $attributes Tag attributes
  */
 public function startTag($parser, $tag, array $attributes)
 {
     $this->empty = true;
     if ($this->tag->isAllowed($tag, $attributes)) {
         $attributes = $this->attribute->filter($tag, $attributes);
         if ($this->attribute->hasRequiredAttributes($tag, $attributes)) {
             $attributes = $this->attribute->addAttributes($tag, $attributes);
             $this->output .= $this->tag->openHtmlTag($tag, $this->attribute->toHtml($attributes));
             $this->empty = false;
         }
     }
     $this->empty_tags[] = $this->empty;
 }