1
votes

I'm currently firing PHP from my Windows Command Prompt. Using:

C:\xampp\php>php -f c:\Uncrypt.php

Which outputs:

 ■< ? p h p e c h o " t t " ; ? >

Which is strange, as according to the help document php -h. The switch of -f should:

-f Parse and execute .

But, this is not working. PHP is correctly installed & working when running through the browser, and:

C:\xampp\php>php -v

Spits out:

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

Copyright (c) 1997-2014 The PHP Group

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

Which means that the command line interface for PHP.exe atleast reaches this.

I have also added sufficient PATHs in the environment variables (both user & system).

After searching, the PATH variables seem to be the root cause, but running PATH does bring out my PHP directory, and there is file associations linked to notepad++ (could this be a possible error?)


As requested, here is the contents of this PHP file (screenshot with encoding to follow)

<?php echo "tt"; ?>

Encoding & File Contents

1
This character: ■ at the beginning of your php file may be the problem, preventing parsing of the file. - sfyn
you're outputting <[space]?[space]p[space]etc.... That's not a PHP tag. it's a bunch of space-separated characters that happen to kind of LOOK like a php tag. it's the difference between MARC and M A R C. one's my name, the other's a list of letters that make up my name. probably your file is in some goofy multi-byte text encoding that php can't parse properly. - Marc B
Actually, could you upload the php file you are trying to execute, please? I copy and pasted the output you provide and it contains whitespace problems and all kinds of issues that are likely preventing php from parsing it. - sfyn
Looks like being saved as UTF-16, not interpreting the - atxdba
@MarcB UTF-8 Is the current files encoding, have tried ASNII also. Both are confirmed to be interpreted with PHP CLI - Daryl Gill

1 Answers

0
votes

You might try without the -f. I've had issues with that before.