thinkphp keyword highlighting

WBOY
Release: 2016-08-08 09:30:43
Original
1222 people have browsed it

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);
}
Copy after login

Then write this in the template variable

{$<pre name="code" class="php">/*
**参数说明
**$sheng为页面输出的变量
**$keywords_red即是描红函数
**###代表第一个参数,即$sheng
**$q代表需要描红的字体,即搜索的关键字
*/
Copy after login

sheng|keywords_red=###,$q}
Copy after login

The above introduces thinkphp keyword tracing, including aspects of content. I hope it will be helpful to friends who are interested in PHP tutorials.

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template