Michal Vlasák
Michal Vlasák

Reputation: 247

NppExec Notepadd++ not expected output

I have the following testing scirpt:

<?php
    echo 'Hello'            // mistake - missing semicolon
    echo 'Hi';          
    echo $hi;               // mistake - undefined variable         
?>

I tried to check this script by NppExec - I used the command:

$(NPP_DIRECTORY)\notepad++.exe -n $(FULL_CURRENT_PATH)

And I got for me an unexpected output:

Process started >>>
<<< Process finished. (Exit code 0)
================ READY ================

I expected some Error message. Does it mean that I use NppExec wrong? Thank you

Upvotes: 0

Views: 196

Answers (1)

Siguza
Siguza

Reputation: 23850

The problem

This command:

$(NPP_DIRECTORY)\notepad++.exe -n $(FULL_CURRENT_PATH)

I don't know what you think it's doing, but here's what it is doing:

This opens Notepad++. Not PHP or anything, just Notepad++. However, since a Notepad++ instance is running already, it just exits.
I don't know if that happens before the arguments take effect, but if it doesn't, then $(FULL_CURRENT_PATH) will be opened as a file and Notepad++ will jump to line 0 in it because of the -n option, which means "scroll to line X". Since you don't give, for example, -n15 but just -n, the line number is zero.

The solution

I presume your goal is to validate the syntax of your PHP file.
For that you need to have PHP installed on your system and have the PHP bin folder in your %PATH% (or use the full path to php.exe below).
Then the NppExec command you're looking for should be:

php.exe -l $(FULL_CURRENT_PATH)

Passing the -l (lowercase L) option to the PHP executable will make it validate the syntax of the input file(s).

Upvotes: 1

Related Questions