php – 带https的preg_replace http
发布时间:2020-12-13 22:14:39 所属栏目:PHP教程 来源:网络整理
导读:简而言之,我需要检查变量$url中的字符串是否是一个简单的http,如果是这样,用https替换它 – 但我无法让它工作 – 任何想法: $url="http://www.google.com"; // example http url ##$url_replaced = preg_replace( '#^http://#','https://',$url ); // repla
简而言之,我需要检查变量$url中的字符串是否是一个简单的http,如果是这样,用https替换它 – 但我无法让它工作 – 任何想法:
$url="http://www.google.com"; // example http url ## $url_replaced = preg_replace( '#^http://#','https://',$url ); // replace http with https ## 干杯! 解决方法
为什么不str_replace?
$url="http://www.google.com"; // example http url ## $url = str_replace('http://',$url ); echo $url; (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |