标签构建
标签构建,PHP实现。br /
标签构建,PHP实现。
<?php function buildTag($tag, $att = array(), $selfColse = FALSE, $inner = ''){ $t = '<'.$tag.' '; foreach($att as $k => $v){ $t .= $k.'="'.$v.'"'; } if(!$selfColse) $t .= '>'; else $t .= ' />'; if(!$selfColse) $t .= $inner.'</'.$tag.'>'; return $t; }Play Angry Birds // Example 1: echo buildTag('input', array('type'=>'button', 'value'=>'WOOT!'), TRUE); // Example 2: echo buildTag('div', array('style'=>'border:solid 1px #000'), FALSE, buildTag('a', array('href'=>'http://google.com'), FALSE, 'Google')); ?>
精彩图集
精彩文章