How to Run a PHP Script with a Image Extension

How to Run a PHP Script with a Image Extension

Have you ever wanted to track views, compile watermarks, etc…?  Well the script below will allow your server to run a jpg image as a php file.  This is why I love PHP so much, people don’t know how much of what they see is powered by PHP.

First, create an .htaccess file in the folder that contains the jpg(s) you would like executed as a php script.  Next, enter the following code in the file:

AddType application/x-httpd-php .php .jpg

Becareful when doing this, make sure you don’t put this command in the root folder.  Also, always worry about your variables and make sure that they are not being used in unethitical ways.

By the way, this will only works for Apache Web Servers.

I hope this lesson was useful :) , please leave your comments below.

About the Author