Home  >  Article  >  Backend Development  >  http://www.12306.cn/mormhweb/k The URL address obtained by PHP for the form is preset http string function code

http://www.12306.cn/mormhweb/k The URL address obtained by PHP for the form is preset http string function code

WBOY
WBOYOriginal
2016-07-29 08:42:511407browse

Copy code The code is 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 "http" or "ftp" and colon ":" in the string. If not, in the character Add "http://" before the string

The above introduces the http://www.12306.cn/mormhweb/k PHP preset http string function code for the URL address obtained by the form, including the content of http://www.12306.cn/mormhweb/k , I hope it will be helpful to friends who are interested in PHP tutorials.

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