Lamez Posted October 14, 2008 Share Posted October 14, 2008 is there a function in php that will return a string as a url or not? Quote Link to comment https://forums.phpfreaks.com/topic/128306-solved-question/ Share on other sites More sharing options...
genericnumber1 Posted October 14, 2008 Share Posted October 14, 2008 is there a function in php that will return a string as a url or not? Huh? Do you mean is there a way to determine whether a string is a url? Quote Link to comment https://forums.phpfreaks.com/topic/128306-solved-question/#findComment-664639 Share on other sites More sharing options...
Lamez Posted October 14, 2008 Author Share Posted October 14, 2008 Yes, but without http:// or www. Quote Link to comment https://forums.phpfreaks.com/topic/128306-solved-question/#findComment-664641 Share on other sites More sharing options...
genericnumber1 Posted October 14, 2008 Share Posted October 14, 2008 There are many regular expressions out for that, but there are no specific php functions that do just that. Quote Link to comment https://forums.phpfreaks.com/topic/128306-solved-question/#findComment-664643 Share on other sites More sharing options...
Lamez Posted October 14, 2008 Author Share Posted October 14, 2008 Hmm, well could you give me an example on how to determined this? Quote Link to comment https://forums.phpfreaks.com/topic/128306-solved-question/#findComment-664645 Share on other sites More sharing options...
genericnumber1 Posted October 14, 2008 Share Posted October 14, 2008 It's pretty annoying to determine a url without http://www., you would end up getting things that aren't urls like asdf.asdf, unless you're very specific about the domain extensions (.com, .net, etc) and you would inevitably leave out some other less common ones like .tc. Not to mention you could run into the problematic ones such as .co.uk. Why not require www. or http:// to match? Google "url regular expression" there are thousands out there. Quote Link to comment https://forums.phpfreaks.com/topic/128306-solved-question/#findComment-664650 Share on other sites More sharing options...
Lamez Posted October 14, 2008 Author Share Posted October 14, 2008 well now I am a bit lost, I used those keywords you suggested, and I found something like this: ^((ht|f)tp(s?)\:\/\/|~/|/)?([\w]+:\w+@)?([a-zA-Z]{1}([\w\-]+\.)+([\w]{2,5}))(:[\d]{1,5})?((/?\w+/)+|/?)(\w+\.[\w]{3,4})?((\?\w+=\w+)?(&\w+=\w+)*)? How do I use this to determined if a string is a url? Quote Link to comment https://forums.phpfreaks.com/topic/128306-solved-question/#findComment-664653 Share on other sites More sharing options...
Zane Posted October 14, 2008 Share Posted October 14, 2008 Maybe you could explain your intentions, then we could help better because the most I can't think to say is to get an array of all the possible domain extensions and run a match on said string Quote Link to comment https://forums.phpfreaks.com/topic/128306-solved-question/#findComment-664657 Share on other sites More sharing options...
Lamez Posted October 14, 2008 Author Share Posted October 14, 2008 Well Zanus, that is a good idea! I have this script I have been working on for days, and almost a week now, and I am pretty sure if you did a search on this website with the keywords ELC, or External Link Checker, you would find numerous results with topics by me. That being said, I am encrypting the get url values, after they have been pinged, and they turn out valid, then I am adding them to the database, then checking to see if it blacklisted or not, well in order to check to see if the string is already encrypted I need to see if it is a url! Well if I go ahead and add http:// to the string I would get something like this http://f051adfaf5d5d0d1, so if a users puts in, lets say, phpfreaks.com, I need to determined that this is a valid link, but how? Quote Link to comment https://forums.phpfreaks.com/topic/128306-solved-question/#findComment-664664 Share on other sites More sharing options...
Zane Posted October 14, 2008 Share Posted October 14, 2008 can you not just ping it Quote Link to comment https://forums.phpfreaks.com/topic/128306-solved-question/#findComment-664700 Share on other sites More sharing options...
Lamez Posted October 14, 2008 Author Share Posted October 14, 2008 lol, wow! one sentence and you solve my problems, well lets hope! Thanks for the suggestion! Quote Link to comment https://forums.phpfreaks.com/topic/128306-solved-question/#findComment-664703 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.