用AI赚第一桶💰低成本搭建一套AI赚钱工具,源码可二开。 广告
## 自制标签taglib 新建一个类 `common/tag/Custom.php` 在config.php文件中 ``` 'template' => [ ... // 标签库标签开始标记 'taglib_begin' => '<', // 标签库标签结束标记 'taglib_end' => '>', 'taglib_build_in'=>'cx,app\common\tag\Custom' //cx为官方的 带加入进去 ] ``` 在`common/tag/Custom.php` 中 ``` namespace app\common\tag; use \think\template\TagLib; class Custom extends TagLib { protected $tags = array( 'testclose' => array('attr' => 'name,content','close' =>0), //默认为对称标签 'testopen' => array('attr' => 'name'), ); /** * 闭合标签 * 注意方法的命名, tag+标签名 标签名大写 */ public function tagTestclose($tag, $content) { $parseStr ="<h1>{$tag['name']}---{$tag['content']}</h1>"; return $parseStr; } //对标签 public function tagTestopen($tag,$content){ $parseStr=''; $parseStr.="<h1>{$tag['name']}</h1>"; $parseStr.="<br/>content: {$content}"; return $parseStr; } } ``` 在`html模版中` ``` <testclose name="测试name" content="测试content"/> <br> <testopen name="name 测试">内容content测试</testopen> ```