I want to run and execute such a script, here is its code from the file:

<html> <head> <title>Пример</title> </head> <body> <?php echo 'Hello!'; ?> </body> </html> 

When doing it in the console, I get this:

 C:\Users\Администратор>cd C:\WebServers\home\test1.ru\www C:\WebServers\home\test1.ru\www>php index.php <html> <head> <title>╨Я╤А╨╕╨╝╨╡╤А</title> </head> <body> Hello! </body> </html> 

Why, when executing the script, in the console I get all this html code, and not the result "Hello!"

Encoding costs UTF-8 (without BOM)

And the word "Example" in the title block in general gives out an incomprehensible encoding.

    2 answers 2

    1. For the same reason, why the browser gets html and not just what you specified in the tags. All that is in the file is the "script execution result".

    2. The windows console, by default, does not understand UTF-8. One solution is described here :

      • open terminal
      • in the properties of the window (right click on the title, item properties), on the font tab, replace with Lucida Console
      • run chcp 65001

    In any case, problems with Russian characters will remain, they may not display everything correctly, so either write for the console commands everything in English, or use the virtual machine for the server and the terminal from the Unix system, or install another terminal.

      It is necessary to remove all html code from the file. Leave only

       <?php echo 'Hello!'; ?>