Ali
Ali

Reputation: 267287

How to find out when a web page was last changed?

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).

Upvotes: 1

Views: 1383

Answers (4)

Cybrix
Cybrix

Reputation: 3318

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

Upvotes: 3

Poelinca Dorin
Poelinca Dorin

Reputation: 9715

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 .

Upvotes: 1

iBiryukov
iBiryukov

Reputation: 1740

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.

Upvotes: 2

Jim
Jim

Reputation: 18863

Sure, just use curl and pull the header out.

I would check out this similar question / answer:

Header only retrieval in php via curl

Upvotes: 1

Related Questions