plznty Posted October 31, 2010 Share Posted October 31, 2010 How can I check to see if a webpage exists with PHP. for example http://www.google.com/ would be true and http://fakeurl32939232.com/filepage.html = false What function/syntax would I have to use? Quote Link to comment https://forums.phpfreaks.com/topic/217387-checking-if-page-exists/ Share on other sites More sharing options...
gevans Posted October 31, 2010 Share Posted October 31, 2010 You could take a look at curl_init http://www.php.net/manual/en/function.curl-init.php Quote Link to comment https://forums.phpfreaks.com/topic/217387-checking-if-page-exists/#findComment-1128755 Share on other sites More sharing options...
rwwd Posted October 31, 2010 Share Posted October 31, 2010 Seeing as php is server side, the only way to really check is by grabbing the data in the URL and checking the data to see if the pattern "php" was anywhere in the URL. But there is a flaw in the logic, because if the site has friendly urls, then that patentially means as there would be no means of checking. Not sure why you would want to be doing this though... Rw Quote Link to comment https://forums.phpfreaks.com/topic/217387-checking-if-page-exists/#findComment-1128756 Share on other sites More sharing options...
gevans Posted October 31, 2010 Share Posted October 31, 2010 Seeing as php is server side, the only way to really check is by grabbing the data in the URL and checking the data to see if the pattern "php" was anywhere in the URL. But there is a flaw in the logic, because if the site has friendly urls, then that patentially means as there would be no means of checking. Not sure why you would want to be doing this though... Rw It seems to me that he wants to use php to see if a URL actually exsist, not if the URL in question is hosted on a server running php. Quote Link to comment https://forums.phpfreaks.com/topic/217387-checking-if-page-exists/#findComment-1128763 Share on other sites More sharing options...
plznty Posted October 31, 2010 Author Share Posted October 31, 2010 I'm having a part of my script input users websites, if the website does not exist I do not want to put that useless information into the database. I need a script just to see if the URL they provided does exist. I don't mind if it leads to a soft 404, aslong as it isn't linking to a page that clearly does not exist. Thanks for help so far. Quote Link to comment https://forums.phpfreaks.com/topic/217387-checking-if-page-exists/#findComment-1128783 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.