Home > Backend Development > PHP Tutorial > 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
Release: 2016-07-29 08:42:51
Original
1454 people have browsed it

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.

Related labels:
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 Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template