php - How to fully test a link? -
I was implementing a very simple table of links in php with a MySQL database and this idea came to my mind : Button "test" that runs a test in all the links.
For example:
http://www.somebodysite.com/somesubdir/somefile.php?id=1
This is a very basic link, however, many errors can occur:
- www.somebodysite is no longer available, they
- the ID was deleted
- Id deleted
- Some files. Many things can not be examined remotely, I think, but other people can do it. How far can i go For the first three items, you can use the function and check that if the response is there, which link elements can you verify remotely?
HTTP / 1.1 200 OK : $ stream = fopen ('http://www.somebodysite.com/somesubdir/somefile.php?id= 1 ',' R '); $ Page source = stream_gate_content ($ stream); $ IsDeletedString = 'Deleted from database'; $ IsDeleted = strpos ($ page source is $ isDeletedString); If ($ isDeleted === is incorrect) {// still there} and {// item was deleted}
$ Response = get_headers ('http://www.somebodysite.com/somesubdir/somefile.php?id=1'); $ ValidCodes = array ('http / 1.1 200 OK', 'HTTP / 1.1301 moved permanently', 'HTTP / 1.1 307 temporary redirect' // Add as many codes as you want); If (id ($ response [$], legitimate code $)) {// it is ok} second {// something is wrong}
but to check, if given ID databse You have to know that some Bodisit's owner tells you that some items were removed. If you know that the string on the page that is presented with a deleted item, then load it and find it (can be useful here). Actually the original example, because I'm not familiar with regular dissemination:
Comments
Post a Comment