STDOUT and STDERR with php.exe on Win XP

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
jsherk
Forum Newbie
Posts: 9
Joined: Fri Jul 13, 2007 10:10 am

STDOUT and STDERR with php.exe on Win XP

Post 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
User avatar
McInfo
DevNet Resident
Posts: 1532
Joined: Wed Apr 01, 2009 1:31 pm

Re: STDOUT and STDERR with php.exe on Win XP

Post 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:
Post Reply