Link does not work without http:// protocols (php) : I use php and I have an input that the user types in a link to his website and the link should appear for others to view it or open it. I'm testing the input and the problem is the link does not work unless I types either http:// or https:// before the mentioned URL and I think some one might just write www.foo.com without writing the hhtp:// .
The link automatically substitutes the http:// or https://with the root of my website ( or at least that's what I guess ), because I'm working with XAMP and the URL appears as so : localhost/MyFooProjectFile/www.foo.com .

How to make links work without the protocols or substitute the none mentioned protocol with the right one before my user's link ?

Note : I know the question might seem stupid (cause who is the idiot who thinks a link could work without protocol), but what makes me wonder is I write in the address bar of my browser www.foo.co and it would take me there, without me menthionioning the protocols.

PLease note that I do not have the code in the time of writing the question. Do not downvote just comment if code is crucial, Thanks.