Page 1 of 1
STDOUT and STDERR with php.exe on Win XP
Posted: Mon Jun 20, 2011 9:57 am
by jsherk
I am using Win XP and I am trying to figure out how this all works...
When I call php.exe or php-win.exe from another script (AutoHotKey in my case), do both of these programs use stdout and stderr?
I know php.exe has a console window and php-win.exe does not, but just need to know how they output the results.
Thanks
Re: STDOUT and STDERR with php.exe on Win XP
Posted: Mon Jun 20, 2011 3:23 pm
by McInfo
If you launch php.exe by clicking its icon in Windows Explorer, a window opens. The window stays open because the php.exe process is waiting for you to type some code. To finish the input, you insert an end-of-file (EOF) character with Ctrl+Z followed by Enter.* PHP runs the input script and terminates, returning control to the process that called it. Nothing is keeping the window open now, so it closes immediately, and no output can be seen. (*Alternatively, you can end the process with Ctrl+C.)
If you first launch a command window (run cmd), then launch php.exe from within that window, you can again input your script as before. However, when PHP terminates, control returns to cmd.exe. Because cmd is able to display standard output, anything generated by the PHP script remains visible.
Other programs can launch command-line programs and receive the standard output. In a PHP script, the exec() function can execute an external program and capture the output lines into an array.
I know almost nothing about AutoHotKey, but I imagine that if the AHK script is unable to capture the output, you might get acceptable results by launching php.exe from cmd.exe.
See also: