how to take a screenshot of a loaded webpage using php?

PHP runs on server side, so to be able to take screenshots you need something to render HTML (a browser-like script) and generate a image of it. This script will do that (wkhtmltoimage too):

HTML2PS: http://freecode.com/projects/html2ps_php

But I still think the best solution will be using javascript. Of course, only the client will have access to the screenshots, and maybe you can upload the image to the server. A client browser is better than any kind of server script.

If that is the case, I would suggest using HTML2CANVAS:

HTML2CANVAS: http://html2canvas.hertzen.com/

The best server solution will be a linux distribution with a google chrome installation and a local script to take screenshots. That is the only way to get accurate screenshots of a web page that may contain javacript/HTML5/animations and other difficult to render stuff.