phphttphttps

Check whether the URL scheme is HTTP or HTTPS


I'm using the following code to add http:// to the URL.

(substr(strtolower($url), 0, 7) == 'http://'?"":"http://").$url

but how can I check whether the original URL contains https? I don't want to use an OR clause.


Solution

  • preg_match("@^https?://@", $url)