how to run php file by double clicking from any folder like html files in windows xp?

Is there any trick to run .PHP files in windows XP from any folder by double clicking like HTML file ?

I use XAMPP but in this we need to put files ina special htdocs folder. I want to run file from any folder, desktop by double clicking.

Related posts

Leave a Reply

3 comments

  1. There is a significant difference in viewing HTML files vs. PHP files:

    HTML files are static files interpreted by the browser. When you open them, the PATH to the HTML file is passes as an argument to the default browser which interprets and displays the file.

    PHP files on the other hand are required to be interpreted by a PHP interpreter (XAMPP, in your case) before the resulting HTML is rendered by a browser. In this case, the local file PATH would have to be translated to the corresponding local URL, then sent to the browser.

    Sample Solution
    You could write a simple script that replaces ‘/var/www/’ with ‘http://localhost:8888/‘ (with a regular expression, for example) and passes that to the browser. Then, associate PHP files with your script.

  2. PHP comes with a command line interface interpreter called php.exe (in Windows). This can be found in the root of your PHP installation directory.

    You will need to associate .php files with this interpreter. That is, go into Tools -> Folder Options -> File types, and register php.exe -f "%1" as the application for the .php file type.

    That said, it’s not very typical to want to ‘run’ a PHP file by double-clicking it – not many people would use PHP the same way they’d use, for example, batch files or shell scripts – PHP is much better suited to generating web pages, ie using it in a web server. Chances are, running PHP outside of a web server is not what you really want to do here. For example, the PHP file will run within a command window and its output will be plain text, and if you want to see its output your script will need to pause or wait for input from standard input itself after terminating.

    More information at Using PHP from the command line