Alan Chen wrote: > Hi, everyone, > > I want to write a small PHP script test.php that can determine whether a > webpage is Google Cached. > > Assuming it is uploaded to www.mysite.com, and I want to use it to check > whether www.yoursite.com is google cached. > > It works as follows: > > The user input the query: > > http://www.mysite.com/test.php?site=www.yoursite.com > > The php script will send the following request to the browser > > http://www.google.com/search?q=cache:www.yoursite.com > > in the background. > > And if the returned result contains a string "This is Google's cache of", > then the page is cached, so the php script can display > > "Your site is cached by Google" > > otherwise, it will say > > "Your site is not cached by Google" > > Just wonder how to implement such a feature, can anyone write a simple > sample so that I can use as a startpoint as I am a totally new guy in PHP > coding > > Thanks to all of you so much > > Alan > > Assuming fopen wrappers are enabled, something like: $site = $_GET['site']; $cache = file_get_contents('http://www.google.com/search?q=cache:' . $site); if (strpos($cache, 'This is Google's cache of') !== false) { echo 'Your site is cached by Google'; } else { echo 'Nope'; } -- Thanks! -Shawn http://www.spidean.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php