php 检查 url 是否包含 http:// 或 https://
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/7468309/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-26 02:44:55 来源:igfitidea点击:
Check whether url contains http:// or https://
提问by user398341
Possible Duplicate:
Check if the url is contains the http or https
What is the code to figure out whether the given URL contains http://
or https://
at the beginning using PHP and regular expressions?
使用 PHP 和正则表达式确定给定 URL 是否包含http://
或https://
在开头的代码是什么?
回答by Mihai Iorga
回答by tasmaniski
if (substr($string, 0, 7) == "http://")
$res = "http";
if (substr($string, 0, 8) == "https://")
$res = "https";
回答by Elitmiar
Maybe this could help
也许这会有所帮助
$_SERVER['SERVER_PROTOCOL'];