method __construct documentation in bbn\Html\Element

function($cfg) { self::_init(); if ( \is_string($cfg) && !empty($cfg) ){ // Looking for classes, IDs, or name (|) in the string preg_match_all("/([\\.|\\||#]{1})([A-z0-9-]+)/", $cfg, $m); $classes = []; $id = false; $name = false; if ( isset($m[0], $m[1], $m[2]) && \count($m[0]) > 0 ){ foreach ( $m[1] as $k => $v ){ if ( $v === '.' ){ array_push($classes, $m[2][$k]); } else if ( $v === '#' ){ $id = $m[2][$k]; } else if ( $v === '|' ){ $name = $m[2][$k]; } } } // Looking for the tag (mandatory) preg_match_all("/^([A-z0-9-]+)/", $cfg, $n); if ( isset($n[0]) && \count($n[0]) > 0 ){ $cfg = ['tag' => $n[0][0]]; if ( (\count($classes) > 0) || $id || $name ){ $cfg['attr'] = []; if ( \count($classes) > 0 ){ $cfg['attr']['class'] = implode(" ", $classes); } if ( $id ){ $cfg['attr']['id'] = $id; } if ( $name ){ $cfg['attr']['name'] = $name; } } } } $cfg = self::cast($cfg); if ( self::checkConfig($cfg) ){ foreach ( $cfg as $key => $val ){ if ( $key === 'tag' ){ $this->tag = strtolower($val); } else if ( property_exists(\get_called_class(), $key) ){ $this->$key = $val; } } $this->update(); } else{ $err[] = self::getError(); if ( isset($cfg['tag']) ){ $err[] = 'Tag: '.$cfg['tag']; } if ( isset($cfg['name']) ){ $err[] = 'Name: '.$cfg['name']; } var_dump($err); } }

BBN is a suite of PHP and JS libraries and VueJS components - all open-source! bbn.io, build applications, the quick way

This website uses cookies to ensure you get the best experience on our website.