As you must have guessed so far, PHP executables can run independently from the web server. If you want to run your PHP scripts as a replacement to Perl scripts they should be transparent to the system. At the head of the document, type #!/usr/bin/php, this will tell the unix system that it needs to run PHP interpreter for the following script - this line would be ignored when you run this script under windows environment and thus you can write scripts with do not depend upon the operating system.
// your PHP code
// goes here
Don't forget to add the PHP tags in the script file, else PHP will not interpret it properly. If you want to suppress the PHP headers use #!/usr/bin/php -q, similarly you can also use any other PHP arguments
Configuring Windows to Executing PHP Scripts
For running PHP scripts on the windows machine you need to associate the PHP files with the PHP interpreter to do this Open Windows Explorer, click on the tools menu and select folder options, click in File Types tab and select new button, type .php in the file extension, click OK.
Now select the PHP entry in Registered File Types list box, click Advanced button, then new, type Run in Action box. In the Application Used to Perform Actions box type C:\PHP\PHP.exe "%1" %* (change the PHP path if its different on your machine, %* is used to send any command line arguments), Click OK, OK again and then Close button, with this windows is now configured to run PHP Scripts. Just double click on any PHP file in Windows Explorer to see it running.
Note : You can also register files with extension (.php3), (.php4) or whatever in the same fashion mentioned above.