spenibus.net
2015-05-02 21:18:35 GMT

Command line PHP under windows - update - console window wait to close switch

This is a follow-up to this: [Command line PHP and Javascript under windows - simple CLI setup](http://spenibus.net/b/p/k/Command-line-PHP-and-Javascript-under-windows-simple-CLI-setup) Even though this was by design, I was getting a bit annoyed by the non-closing console window. This might be applicable to the javascript version but since I don't use it as much I haven't bothered. **run.bat** ```` @call "F:/progs/WAMP/php/php.exe" -f %* :: keep console open if exit code is not 1 @if %ERRORLEVEL% NEQ 1 ( @echo. @set /p="Hit ENTER to exit" ) ```` This will remain open: ```` <?php echo "hello there"; ?> ```` This will close immediately: ```` <?php echo "hello there"; exit(1); ?> ```` Alternative, if you don't want to use the exit code -- **run.bat** ```` @call "F:/progs/WAMP/php/php.exe" -f %* ```` This will remain open: ```` <?php echo "hello there"; echo "\npress enter to exit"; fgets(STDIN); ?> ````