Home > php教程 > php手册 > PHP为表单获取的URL 地址预设 http 字符串函数代码

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

WBOY
Release: 2016-06-13 12:16:18
Original
790 people have browsed it

复制代码 代码如下:


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


该代码先用正则表达式检查字符串中是否有"http”或"ftp"和冒号":",如果没有,在字符串前添加"http://"
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template