Add http:// prefix to URL when missing

前端 未结 10 1229
谎友^
谎友^ 2020-11-30 06:41

Hello I have a very simple code


    
Website
10条回答
  •  长情又很酷
    2020-11-30 07:06

    You also may take into account that "http(s)" must be at the beginning of the url:

    if (preg_match('/^https?:\/\//', $aProfileInfo['Website']) === 0) {
        $aProfileInfo['Website'] = 'http://'.$aProfileInfo['Website'];
    }
    

提交回复
热议问题