How to use php to automatically obtain the keyword of the article content During website construction in Jinan

Source: Internet
Author: User
In Jinan website construction, how can I use php to automatically obtain the keyword of the article content. Pnbsp; nbsp; ahrefwww.0531soso. comtarget_blkstrong: anyone who knows about website optimization in Jinan website construction stronga knows well about a website.

Jinan website constructionPeople who know about website optimization are very clear. for a website, the optimization of the website's internal structure plays a decisive role in crawling search engine spider. The better the website is, the longer the search engine crawls, the longer the depth and time. The pattern of spider crawling also has many factors, such as the website weight, website content quality, and spider type, which will determine the depth of website crawling.

How can it be regarded as a good internal optimization of the website? the internal optimization of the website can be divided into two parts: one is the optimization of the internal code of the website, which includes the use specification of html tags, the use of DIV + CSS is skillful. The second is the optimization of the website structure. the final analysis of the website structure is to make the internal structure of the website conform to people's browsing habits, you can quickly and conveniently find what you like when you browse any page of your website.

To improve the internal structure of the website, let the visitor find the appropriate valid information at the appropriate location. Adding the function of automatically obtaining keywords in articles on the website makes it a good choice. I think, when you browse an article on the website, at the end of the article, there are related keywords in this article, and the related search information in this article, it is possible that you will continue to look at the content related to this article, thus reducing the bounce rate of the website and improving the network browsing ability.

I. idea of automatic keyword acquisition in the article content

Obtain the extracted content through php, use the word segmentation method defined in the dictionary to perform word segmentation on the obtained content, and finally perform the final matching of the obtained content, returns the final result to the function as an array.

II. implementation of automatic keyword acquisition in the article content

First, we downloaded the dictionary file, the function, and the test file, and then opened the index. php file, and delete the // print_r (get_tags_arr ($ con) in the code. run this file to check whether the output is output in minutes. Shows the normal output result.

As shown in the figure, you only need to use the get_tags_arr function to obtain the required texts. the implementation method in the code is as follows:

<? PHP

$ A = trim (strip_tags (content ('jianjie '); // Obtain the text part of the keyword to be extracted and remove the html tag and space tag from the text.

$ Arr = get_tags_arr ($ a); // use the get_tags_arr function to perform word segmentation and return an array

Foreach ($ arr as $ k => $ val ){

Echo "<a href = '/search. php? Key = $ val 'title = '$ val 'target =' _ blank '> $ val </a> & nbsp ;";

}

// Use foreach to loop the array and output the html format

?>

Through the above steps, we will find that we have obtained the desired word splitting result, which is so simple that the function of automatically obtaining keywords in the content of the article is complete.

III. Common Errors in automatically obtaining keywords in articles

① Html tags appear in word segmentation keywords

Solution: add the strip_tags () function before the output content to remove the html tag from the output content.

② Garbled characters in the output

Solution: transcode the word splitting before output. the Function mb_convert_encoding () is used ().

③ Garbled characters may occur in different browsers after word segmentation and transcoding.

Solution: determine the browser type and set whether to transcode word segmentation. the strpos function ($ _ SERVER ['http _ USER_AGENT '] is used.

In progressJinan website constructionIn the process of website construction, we need to remember to handle every detail of the website as much as possible. In fact, like the function of automatically extracting keywords from the website content, for general websites, this function is dispensable, and even does not affect the normal development and operation of the website. However, considering the user experience of the website, adding such a function appropriately will greatly improve the readability and attractiveness of the website, and thus increase the weight and keyword ranking of the website.

Author a href = http://www.0531soso.com target = _ blankstrong Jinan website construction/strong/a to understand the site optimization staff are very clear, for a website to come...

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.