How to use PHP to automatically get article content keyword _php tutorial in Jinan website construction

Source: Internet
Author: User
Jinan website ConstructionThe people who understand the optimization of the website are very clear, for a website, the optimization of the internal structure of the site for the search engine spider crawling play a decisive role. Web site optimization of the better the search engine spider crawling depth and time will be longer and deeper. Indifferent spider crawling laws there are many factors, such as website weight, site content quality, spider type, etc., will determine the depth of the site crawl.

How is the site optimization of the good, the site optimization can be divided into two parts, one is the optimization of the internal code of the site, which includes the use of HTML tags, div+css use optimization techniques two aspects. The second is the optimization of the structure of the website, the optimization of the structure of the website is to allow the internal structure of the site in line with people's browsing habits, can be in the site browser on any page of the site to browse the time can quickly and easily find their favorite things.

We get to the point where we want to improve the internal structure of the site, so that the visitors in the appropriate location, to find the appropriate effective information. It's a good choice to add the ability to automatically get keywords in the articles on your website. Imagine, when you on the site of an article to browse, at the end of the article, there are related keywords, this question related search information, both possible you will continue to look down and this article related content, thereby reducing the site bounce rate, improve the network can browse.

First, the idea of automatic acquisition of the article content keywords

By getting PHP to get the content needed to extract, through the dictionary defined in the word breaker, the obtained content of the word breaker, and finally the resulting sub-final match, the resulting results are returned in the form of an array to the function.

Second, the article content keyword Automatic Acquisition implementation method

First we download the already written dictionary file and the sub-function and test file to the local, and then open the index.php file in it, the//print_r (Get_tags_arr ($con)), this line of code to delete, run this file to see if there is a sub-output. The normal output results are as shown.

Through the graph can see, only need to make get_tags_arr this function to get we need the sub-text to be able, the code in the implementation method:

<? Php

$a =trim (strip_tags (Content (' Jianjie ')); Get the text portion of the keyword you want to extract and remove the HTML tags and space tags from the text

$arr =get_tags_arr ($a); Use the Get_tags_arr function to Word-breaker the text and return the array

foreach ($arr as $k = = $val) {

echo "<a href= '/search/search.php?key= $val ' title= ' $val ' target= ' _blank ' > $val </a> &nbsp;&nbsp; &nbsp; ";

}

Loops the array through foreach and prints the HTML format

?>

Through the above steps will find that we have to get their own desired word segmentation results, it is so simple, the article content automatically get the keyword function is completed.

Third, the article content automatically get keywords common errors

HTML tags appear in ①, word breaker keywords

Workaround: Add the Strip_tags () function before outputting the content, removing the HTML tags from the output.

②, garbled in output characters

WORKAROUND: The word breaker is transcoded before the output, using the function mb_convert_encoding ().

③, in different browsers, word breaker after transcoding, garbled phenomenon occurs

Workaround: By judging the browser type, set whether the word breaker needs to be transcoded, using the function Strpos ($_server[' http_user_agent ').

In the process of building a website in Jinan , we need to work on the site construction of customers, we should remember as far as possible to the site of every detail to deal with, in fact, like site content automatically extract the key word this function, for the general website is optional, Even in practice not to join this feature on the normal development and operation of the site has no impact, but in view of the site user experience, the appropriate inclusion of similar features, to a large extent to help improve the readability and attractiveness of the site, thereby improving the site's weight and keyword ranking.

http://www.bkjia.com/PHPjc/755793.html www.bkjia.com true http://www.bkjia.com/PHPjc/755793.html techarticle pnbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp, a href=http://www.0531soso.com target=_blankstrong Jinan website Construction/strong/a Understand the site optimization of the people are very clear, for a website to ...

  • 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.