if http:// is in string then leave it, else if not add it

后端 未结 8 2132
执念已碎
执念已碎 2020-12-22 12:07

I have a input that you enter a URL, i basically want to write some php that says if the domain containts \"http://\" then leave it be, else if not then add it to the beginn

8条回答
  •  情深已故
    2020-12-22 12:56

    Since the string starts with http://, strpos will return 0, which will evaluate to false.

    Change the if statement to:

    if(strpos($domain, "http://") !== FALSE){
    

提交回复
热议问题