简体   繁体   中英

validate a url and then split it into the url and the domain name

Let say I have got a url

http://ex.com/blah?balchs

What I wanna do is to validate if the url is valid. The url

ex.com and /blah?balchs

How can I do this?

Also if I wanna validate if the domain exists and is up and running how do I do that? Also if I wanna validate if the url exists and is up and running how do I do that?

You can try using built-in php functions for the first part, namely parse-url .

For the latter, it kinda depends on what you mean by "exists" and "running". The simplest technique is to do a ping and check if that succeeded. But this can be faulty at times. If the target machine is certain to have a port opened you can try fsockopen .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM