Well this is a Web Server issue not PHP, since PHP gets called by the web server when a file is to be parsed by the PHP Engine. What you want is mod_rewrite so something like this

untested

RewriteEngine on
RewriteRule ^([a-z]+)$ $1.php [NC]

Of course you may want to check the file actually exists and that it is a file and not a directory.

    okay, great...where would i put that piece of code? can you give me an example?

      you need to put it in a .htaccess file. you might want to read up a little first on what mod_rewrite is, and how it works.

        4 years later

        hi where we should keep that htaccess file? actually that above code is not working for me thats why i am asking . Can anyone help me..

          Write a Reply...