Home > Article > Backend Development > thinkphp keyword highlighting
First define a function in function.php:
//关键字描红 function keywords_red($string,$keywords=''){ if(empty($keywords)||empty($string)) return $string; return str_replace($keywords,'<span class="red">'.$keywords.'</span>',$string); }
{$<pre name="code" class="php">/* **参数说明 **$sheng为页面输出的变量 **$keywords_red即是描红函数 **###代表第一个参数,即$sheng **$q代表需要描红的字体,即搜索的关键字 */
The above introduces thinkphp keyword tracing, including aspects of content. I hope it will be helpful to friends who are interested in PHP tutorials.