A
A
Andrey Ovsyankin2014-08-07 10:12:22
Apache HTTP Server
Andrey Ovsyankin, 2014-08-07 10:12:22

How in IIS (or in Apache) does the script handler get the path to the script?

Let's say we set up a bunch of php.exe and IIS. We added a bunch of *.php extension and php.exe interpreter
In the browser, we request mysite/script.php and the web server starts the interpreter, indicating to it the path to the requested script. Everything works well.
Question: How does the interpreter get this path? I assumed it was a command line option. However, if I write my own exe and set it up as a php file handler, then there is nothing in the command line options.
How should I, as the author of the script processor, get the path to the requested script file?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Andrey Ovsyankin, 2014-08-07
@EvilBeaver

Already dug up on my own. Maybe it will be useful to someone:
1. The name of the script is passed through the SCRIPT_FILENAME or PATH_TRANSLATED environment variable
2. The command line arguments are always empty
3. The GET data is passed in the QUERY_STRING environment variable
4. The POST data is passed through the stdin input stream

M
memba, 2014-08-07
@memba

I can tell you that php.exe is the console version of the interpreter, which is used for console scripts, not for running through a web server. External data is, of course, passed to such a program as command line parameters.
There is also php-cgi.exe, which is a CGI version of the interpreter. I can assume that to transfer information, a stream will be used here. According to the CGI version, the interpreter, along with the path to the script, should receive a bunch of other information. For example, all the headers and data of GET and POST...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question