J
J
JackShcherbakov2018-02-22 21:01:24
PHP
JackShcherbakov, 2018-02-22 21:01:24

How to solve encoding problem in php?

Hello! All commands and operations work as they should. But the execution operation does not work as I want.
Here is the code:

<?php
  $a = `dir c:`;
  print  "<pre>" . $a . "</pre>";
?>

Here is the result:
��� � ���ன�⢥ C �� ����� ��⪨.
 ��਩�� ����� ⮬�: 2E4C-FF6A

 ����ন��� ����� C:\OpenServer\domains\comet

17-02-2018  16:28    
          .
17-02-2018  16:28    
          ..
22-02-2018  15:48               340 js.html
22-02-2018  20:55                60 php.php
               2 䠩���            400 ����
               2 �����  39�821�983�744 ���� ᢮�����

How to fix? Why is the problem only with the execution operation?
Thanks in advance!

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Sergey delphinpro, 2018-02-22
@delphinpro

Windows uses cp1251 encoding.
OpenServer is set to utf8 by default.
Hence the output
Either convert the output of the execution statement to utf-8.
Or reconfigure the server.
The first is preferable, the
second if you plan to run the script only on your own.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question