1

Is there a way to find out when a web page was last changed using PHP? (The web page is hosted on a different website).

Ali
  • 261,656
  • 265
  • 575
  • 769

4 Answers4

3

You could use that lame method :

$checksum = md5(file_get_contents("http://www.site.com"));

You can store that value and compare it later.

Good luck

Cybrix
  • 3,248
  • 5
  • 42
  • 61
2

Last-Modified header in http. But there is no guarantee it will function correctly. Last modified header can be set incorrectly, or not set at all.

iBiryukov
  • 1,730
  • 4
  • 19
  • 30
1

Sure, just use curl and pull the header out.

I would check out this similar question / answer:

Header only retrieval in php via curl

Community
  • 1
  • 1
Jim
  • 18,673
  • 5
  • 49
  • 65
1

Using cUrl , you can check the headers but if they are not set corectly then you're lost . The only thing i can think of is testing if the content has chaged , you can get the contet of the homepage with cUrl or file_get_contents() ( if it's allowed on you're host ) , hash it and save it in a database , then when you whant to check again you can make a cUrl request , hash the result and check with the one you got in you're database .

Poelinca Dorin
  • 9,577
  • 2
  • 39
  • 43
  • @Cybrix: maybe if you didn't posted it nobody would have noticed mine since i didn't entered any code ( usualy works that way around here ) , it should be all good if the right answer was aproved ( doesn't matter if it's mine or you'res , we both try to help ) . – Poelinca Dorin Jan 08 '11 at 02:45