PHP code example of agrism / php-html

1. Go to this page and download the library: Download agrism/php-html 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/ */

    

agrism / php-html example snippets




use Agrism\PhpHtml\Builder\Attribute;
use Agrism\PhpHtml\Builder\Element;

$table = Element::factory('table')
  ->addAttribute(Attribute::factory('border')->setValue(1))
  ->addContent(
    Element::factory('tr')->addContent(
        Element::factory('td')
          ->addContent(
            Element::factory()
              ->addValue('A')
              ->addValue('B')
              ->addValue('C')
          )
          ->addContent(
            Element::factory('table')
              ->addAttribute(Attribute::factory('border', 3))
              ->addAttribute(Attribute::factory('style', 'background-color:red;'))
              ->addContent(
                Element::factory('tr')
                 ->addContent(
                   Element::factory('td')
                     ->addContent(
                       Element::factory()->addValue(5)
                     )
                 )
                 ->addContent(
                   Element::factory('td')
                     ->addAttribute(Attribute::factory('style', 'background-color:blue;'))
                     ->addContent(
                      Element::factory()->addValue(15)
                     )
                 )
              )
          )
       )
);

Element::factory('html')
  ->addContent($table)
  ->addContent($table)
  ->setEchoValue()
  ->render();



use Agrism\PhpHtml\Table\Table;

Table::factory()
  ->addAttribute('border', 13)
  ->addRows([
      ['p1', 'p2', 'p3'],
      ['p11', 'p22', 'p33'],
    ], 
    ['style' => 'background-color:yellowgreen;']
  )
  ->addHead(['title1', 'title2', 'title3'], ['border' => 1, 'style' => 'background-color:brown;'])
  ->addHead(['title11', 'title22', 'title33'], ['border' => 1, 'style' => 'background-color:blue;'])
  ->addRow(['a', 'b', 'c'], ['style' => 'background-color:red;'])
  ->addRow(['a1', 'b1', 'c1'], ['style' => 'background-color:yellow;font-size:28px;color:blue;text-align:right'])
  ->addRow(['a2', 'b2', 'c2'])
  ->render();     




use Agrism\PhpHtml\Table\Table;

$nestedTable = Table::factory()
	->addAttribute('border', 13)
	->addRow(['A', 'B'])
	->getOutput();

Table::factory()
	->addAttribute('border', 1)
	->addRow([1,2,3, $nestedTable])
	->render();

git clone git://github.com/agrism/php-html.git