Php checks whether there is an external link in the string. php string _ PHP Tutorial

Source: Internet
Author: User
Php checks whether there is an external link in the string. it is a php string. Php checks whether there is an external link in the string. The php string example in this article describes the php checks whether there is an external link in the string. Share it with you for your reference. The specific implementation method is as follows: php checks whether there is any external link in the string, and php string

This example describes how to check for external links in strings in php. Share it with you for your reference. The specific implementation method is as follows:

/*** Is_external_link: Check whether the string contains External links * @ param string $ text * @ param string $ host domain name * @ return boolean false there is external link true no external link */function all_external_link ($ text = '', $ host = '') {if (empty ($ host) $ host = $ _ SERVER ['http _ host']; $ reg = '/HTTP (? : S ?) :\/\/((? : [A-za-z0-9-] + \.) + [A-za-z] {2, 4})/'; preg_match_all ($ reg, $ text, $ data); $ math = $ data [1]; foreach ($ math as $ value) {if ($ value! = $ Host) return false;} return true ;}

I hope this article will help you with php programming.

Examples in this article describes how php checks whether strings contain external links. Share it with you for your reference. The specific implementation method is as follows...

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.