Validating url c
FXCop agrees: msdn.microsoft.com/en-us/library/bb386039method, there's no need to throw an exception.
You just have to notify the caller whether the conversion succeeded or not.
//url = " //Prints "BROKEN" althought this should be good.
This indicates that something uncontrollable by the caller is getting thrust in their lap.
Each of these functions has its own strengths and weaknesses.
Recommendations So what is the recommended validating function?
Source: The URLs to be Tested Below are the URLs to be tested against the above URL validating functions. Validating function #4 does have zero slippage, but it over-judges 87.5% of the time. The filter_validate_URL function, which is the #5 validating function, averages 31.62%.Second, in PHP, there is a function called parse_url: .You can feed it the output of validated URLs to retrieve the host name and other information for further processing, instead of using string manipulation functions; it saves time. You can use this function to check if the URL actually exists.For example, validation function #1’s main weakness is that it will not be able to validate valid capitalized URLs or IP addresses.One way you can further improve the function is to convert all URLs to lower case before inputting them into the validating function.