Home > Backend Development > PHP Tutorial > 一个按钮 提交 输入框的网址,怎么判断是否在网址前面添加 http://

一个按钮 提交 输入框的网址,怎么判断是否在网址前面添加 http://

WBOY
Release: 2016-06-23 14:06:09
Original
1122 people have browsed it






提交的时候, 怎么判断 输入的 $sqldb[link]  是否有http://
如果有则正常提交,
如果没有则 自动 添加http:// 提交


回复讨论(解决方案)

擦,截取前7个字符,再判断下是不是http://不就OK了 PHP资料

能帮忙写个例子么,急用, 有空再慢慢看。

$str=stristr($_POST['link'],'http://') ? $_POST['link'] : 'http://'.$_POST['link'];
Copy after login

PHP code?1$str=stristr($_POST['link'],'http://') ? $_POST['link'] : 'http://'.$_POST['link'];

或者用正则表达式也行。

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