trying to create a function to quickly test a URL
Posted: Wed Apr 21, 2004 7:30 pm
greets, i'm new here.
as my topic says, i am attemtping to create a function to quickly verify the existence/validity of a URL.
so far i have been trying to pass a single parameter called $target. this is a string variable containing the hyperlink to be tested. in theory this function should return a boolean true if the link exists and a boolean false if it doesn't or isn't accessible.
i have a function which does this coded but my problem is this: if the target doesn't exist, the function takes a really long time to give up and return false.
before i post my current code, i'm curious if anybody has a way to implement this function and keeping its execution time limited to a variable number of seconds (in my impatient case, 1). i have been thinking of adding a second parameter to pass in a timeout time in seconds, but at this point i can't even get the function to work as is, so i am not worried about nicing it up yet...
as my topic says, i am attemtping to create a function to quickly verify the existence/validity of a URL.
so far i have been trying to pass a single parameter called $target. this is a string variable containing the hyperlink to be tested. in theory this function should return a boolean true if the link exists and a boolean false if it doesn't or isn't accessible.
i have a function which does this coded but my problem is this: if the target doesn't exist, the function takes a really long time to give up and return false.
before i post my current code, i'm curious if anybody has a way to implement this function and keeping its execution time limited to a variable number of seconds (in my impatient case, 1). i have been thinking of adding a second parameter to pass in a timeout time in seconds, but at this point i can't even get the function to work as is, so i am not worried about nicing it up yet...