1
votes

I have a simple test PHP file:

<?php echo exec('php -v');

When I execute php -v in Git Bash, the console displays:

PHP 5.6.3 (cli) (built: Nov 12 2014 17:18:08)

Copyright (c) 1997-20147 The PHP Group

Zend Engine v2.6.0, Copyright (c) 1998-2014 Zend Technologies

But, when I execute php test.php the console displays:

‘php’ is not recognized as an internal or external command, operable program or batch file.

If I execute php test.php in cmd.exe this works and displays:

Zend Engine v2.6.0, Copyright (c) 1998-2014 Zend Technologies

Note: I have Windows 8.1 and Git Bash 2.7.1.2

SOLVED

I had deleted folders in my PATH var, this isn't a problem for cmd.exe but, in Git Bash I don't know why doesn't work.

I deleted the deleted paths from PATH and it works.

1

1 Answers

0
votes

Re-install Git, and make sure to tick the Run Git from the Windows command prompt option.

Also, if Git is freshly installed, you might need to restart your PC for the new PATH variable to be recognized (the way "php" is globally recognized rather than setting a path to the php actual executable).