开发者

Check whether url contains http:// or https:// [duplicate]

This question already has answers here: Closed 11 years ago.

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 P开发者_开发技巧HP and regular expressions?


you can use parse_url

<?php
   $url = parse_url('https://example.org');

   if ($url['scheme'] == 'https') {
       // is https;
   }
?>


if (substr($string, 0, 7) == "http://") {
   $res = "http";
}

if (substr($string, 0, 8) == "https://") {
   $res = "https";
}


Maybe this could help

$_SERVER['SERVER_PROTOCOL'];
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜