PHP code example of umbrella / tag-builder

1. Go to this page and download the library: Download umbrella/tag-builder library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

umbrella / tag-builder example snippets


  $linkTag = new \Umbrella\TagBuilder\TagBuilder('a');
  
  //Adds a href attribute to the tag
  $linkTag->mergeAttribute('href', '#');
  
  //Adds a css class to the tag
  $linkTag->addCssClass('your-custom-css-class');
  
  //Adds a text or a html to some tag
  $linkTag->setInnerHtml('Your link text');
  
  //Renders the tag...
  echo $linkTag->toString(\Umbrella\TagBuilder\TagRenderMode::NORMAL);
  
  
  // ... or render like this
  echo $linkTag;
  
  //Both will print <a href="#" class="your-custom-css-class">Your link text</a>


\Umbrella\TagBuilder\TagRenderMode::NORMAL

\Umbrella\TagBuilder\TagRenderMode::START_TAG

\Umbrella\TagBuilder\TagRenderMode::END_TAG

\Umbrella\TagBuilder\TagRenderMode::SELF_CLOSING