检查字符串中是否有外链
2015-11-07 10:00
260 查看
<?php /** * all_external_link 检测字符串是否包含外链 * @param string $text 文字 * @param string $host 域名 * @return boolean false 有外链 true 无外链 */ 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; } ?>
相关文章推荐
- 制作JAR
- 恶意代码清除实战
- 打开qt出现提示无法覆盖文件 /home/xxx/.config/Qtcreator/qtversion.xml : Permission denied
- php中的常量
- 第五次实验 稀疏矩阵的存储和快速转置
- 【C#】MouseEventArgs事件参数获取鼠标的位置
- 既然选择了、再怎么艰难也要走下去
- 《九护》一款只专注于老人实时定位的应用
- 黑马程序员——java基础---集合(上)
- 既然选择了、再怎么艰难也要走下去
- Nginx + IIS
- SEL类型
- POJ2407-Relatives(欧拉函数裸题)
- 【转】Android sdk content loader 0%的解决方案
- hdu 1087 Super Jumping! Jumping! Jumping!
- 抽象类和接口的区别
- UML学习(三):序列图(顺序图/对象顺序图)
- C#影院售票系统毕业设计(4)
- 【转载】解决HIS集群系统的性能问题一例
- SqlServer中的Char、Varchar和Nvarchar详解