I've recently made a new website and I'm using a template. See this image (link):

enter image description here

The file extention is .php. Can anyone explain this?

NOTE: When an image is posted here, stackexchange creates it's own location to store it. If you're right clicking and saving the pic in the question, you'll get a .jpg. But, right click on the picture here.

Here are screenshots of what happens when I try to save it:

Save as


  • Were you able to get the .php and display it as an image, even when dowloaded? (the upload is indeed unrelated).
    – Vincent
    Oct 24, 2013 at 11:41
  • I don't know what you're asking... Try to save the image in the question now.
    – BBking
    Oct 24, 2013 at 11:42

2 Answers 2


A PHP script on the server (which is what the URL causes to be run) returns a response to the browser which contains the header

Content-Type: image/jpeg

so the browser knows that what is returned is a JPEG image and displays it accordingly.

The browser uses the response headers to determine what to do with content. Client operating systems may behave differently — Windows, for example, has a heavy dependence on the filename extension. But if you attempt to save the image from the browser on a Windows system, you may find it's given a .jpg extension because the browser knows it's a JPEG image.

  • Thanks, that's a bit more help. But what would it take to explain why when I go to save the image, it saves it as rotate.php rather than sample-image.jpg ?? Source?
    – BBking
    Oct 24, 2013 at 11:45
  • Depends on your browser. When I try and save it in Firefox on Windows, it suggests rotate.php.jpg. Answer updated. Oct 24, 2013 at 11:52
  • I'm using Windows 7, Chrome Version 30.0.1599.101 m.
    – BBking
    Oct 24, 2013 at 12:02
  • Well there you are. Chrome doesn't add an extension which Windows will understand correctly. Oct 24, 2013 at 12:20
  • @bbking: in CMS (content management systems) which support templates, the actual image file names and locations may be stored in a database (sometimes even the data for the image is stored in the database as well). They do this so that the scripts for the site only need reference an abstract concept of "sidebar image." Your example, the abstraction is "rotate.php" which presumably looks up the image content and then passes it through to your browser.
    – horatio
    Oct 24, 2013 at 14:11

It's still encoded like a "jpeg" or "png". A server can send back an image and say it's Content-Type: text/html with filename image.php and the browser will still render it as png. That's why saving it will attach the .png extension even though image.php didn't have it.

.php is not an image format, but, .php can return an image. It can be used to run some processing on the image and creating a compressed/smaller version depending on the size of the image requested.

Here's an explanation of how the browser handles images put in the src tag. https://stackoverflow.com/a/5110673/9225733 for those who are interested.

  • 1
    its a 2013 question.. and it's not about design It's about scripting and functionality of web servers. You yourself linked to SO.. to explain functionality of server side scripting and web browsers.. that's not design.
    – Scott
    Feb 2 at 9:07
  • That's a fair point and I agree that it's more technical than most questions here. Still, designers need to know the difference between png, jpg and svg so "what is a .php" is a valid question IMO. I answered 11y later since the answer is incomplete, I found an exceedingly rare case over here: takk.is/vara/pads-17-brunn which is not explained by the above answer.
    – Caveman
    Feb 5 at 12:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.