Zakarakus
Zakarakus

Reputation: 49

PHP hangs when run from CMD

I have PHP added as an env variable - set to C:\Program Files\PHP\v7.3, but when I run php from CMD the window locks up and it just hangs indefinitely. When run "C:\Program Files\PHP\v7.3\php.exe" directly then the interactive shell starts normally.

No errors in the event log. Microsoft Visual C++ 2019 redistributable is installed. No other versions of PHP present (though there was an old version installed historically).

Upvotes: 1

Views: 927

Answers (2)

lotfio
lotfio

Reputation: 1936

To run PHP in an interactive mode you need to pass the -a flag

example :

php -a or C:\Program Files\PHP\v7.3\php.exe -a

Running both php or C:\Program Files\PHP\v7.3\php.exe will cause the terminal to hang and a CLI php process to start

You can quit the process by pressing Ctrl + C

Upvotes: 1

Ar Rakin
Ar Rakin

Reputation: 542

Running only the php command will cause this problem. php -r command can be used to run PHP code on CLI. Example: php -r 'echo "Hello world!";'

Upvotes: 0

Related Questions