复制代码 代码如下:

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

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

点赞(101)

评论列表共有 0 条评论

立即
投稿
返回
顶部