PHP为表单获取的URL 地址预设 http 字符串函数代码


复制代码 代码如下:

if (!preg_match("/^(http|ftp):/", $_POST['url'])) {
$_POST['url'] = 'http://'.$_POST['url'];
}

该代码先用正则表达式检查字符串中是否有"http”或"ftp"和冒号":",如果没有,在字符串前添加"http://"
« 
» 
快速导航

Copyright © 2016 phpStudy | 豫ICP备2021030365号-3