I am working on a social network and when the user comments on an address url
, it is taken as a simple comment.
I would like that when I put an address url
there it is when I give click
it to take you to that address.
For example , facebook
a user sends a url
chat and clicking click
takes you to that page.
You could start by validating that the
String
input is aURL
. You can usefilter_var()
:We can take advantage of certain patterns in the url's, for example the use of
www
,http
,https
to detect a possible url:Or we can use filter_var() to validate: