Copy code The code is as follows:
if (!preg_match("/^(http|ftp):/", $_POST[' url'])) {
$_POST['url'] = 'http://'.$_POST['url'];
}
This code first uses regular expressions The expression checks whether there is "http" or "ftp" and a colon ":" in the string. If not, add "http://" in front of the string.
http://www.bkjia.com/PHPjc/321864.htmlwww.bkjia.comtruehttp: //www.bkjia.com/PHPjc/321864.htmlTechArticleCopy the code as follows: if (!preg_match("/^(http|ftp):/", $_POST ['url'])) { $_POST['url'] = 'http://'.$_POST['url']; } This code first uses a regular expression to check whether there is "...
Statement: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