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

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

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOriginal
2016-06-23 14:06:091159browse






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


回复讨论(解决方案)

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

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

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

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

或者用正则表达式也行。

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
Previous article:yii 表单 还可以是两列啊?Next article:求解答~