I am getting a link and in it there is a href… I want to know if it’s a
http://[...].com/file.txt absolute domain name
or
/file.txt
a link that does not have the full URL.
How can I do this with PHP?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Use
parse_urland see if you get a scheme and host. For example, this:Produces:
Live example: http://ideone.com/S9WR2
This also allows you to check the scheme to see if it is something you want (e.g. you’d often want to ignore
mailto:URLs).