可能重复:
检查URL是否包含http或https
什么是用于确定给定URL是否包含http://或https://在开头使用PHP和正则表达式的代码?
Mih*_*rga 26
你可以使用parse_url
<?php
$url = parse_url('https://example.org');
if($url['scheme'] == 'https'){
// is https;
}
?>
Run Code Online (Sandbox Code Playgroud)
tas*_*ski 10
if (substr($string, 0, 7) == "http://")
$res = "http";
if (substr($string, 0, 8) == "https://")
$res = "https";
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
28352 次 |
| 最近记录: |