V
V
Vladimir Tyutimov2015-03-20 11:14:08
PHP
Vladimir Tyutimov, 2015-03-20 11:14:08

Why doesn't the ASSIGNMENT OPERATOR work!?

Hello. There is a code:

if(!empty($_GET['dost_index']) && !empty($_GET['dost_address']))
  {
      $dost_index = (int)$_GET['dost_index'];
        $dost_index = (string)$dost_index;
        $dost_address = substr(str_replace(array('"', '`', "'", '\\'), '', trim(strip_tags($_GET['dost_address']))), 0, 1500);
    		$dost_res = 'Индекс: '.$dost_index."\n".'Адрес: '.$dost_address."\n";
  }
$xml .= "Способ доставки: Доставка почтой россии!\n"; 
      $like_mail .= "Способ доставки: Доставка почтой россии!\n";

$xml .= "\nКомментарий\n".iconv("windows-1251","utf-8", $_GET['comment'])."\n";
    $like_mail .="\nКомментарий\n".iconv("windows-1251","utf-8", $_GET['comment'])."\n";

if(!empty($dost_res))
  {
      $xml .= iconv("windows-1251", "utf-8", $dost_res);
      $like_mail .= iconv("windows-1251", "utf-8", $dost_res);
  }

The problem is that the line $like_mail .= iconv("windows-1251", "utf-8", $dost_res); (She is the last one) does not work.
More precisely, the contents of the $dost_res variable do not end up in the $like_mail
variable. If you write this: $like_mail .= "Some text".iconv("windows-1251", "utf-8", $dost_res); , then the text in quotation marks will be added. and the contents of the $dost_res variable are not.
The variable is not empty, I checked.
What could be the reason, tell me please?

Answer the question

In order to leave comments, you need to log in

3 answer(s)
O
Oleg, 2015-03-20
@BidiBom

1. do this:
var_dump($dost_res);
var_dump(iconv("windows-1251", "utf-8", $dost_res));
$like_mail .= iconv("windows-1251", "utf-8", $dost_res);
2. run the script.
what brought it out?
99% that dost_res is empty or cannot be adequately converted from windows-1251 to utf-8

L
Leonid Sysoletin, 2015-03-20
@sysoletin

Look at the error log. Most likely, some wrong character got into $dost_res, and //TRANSLIT or //IGNORE should be used.

A
Andrey Mokhov, 2015-03-20
@mokhovcom

obviously: iconv returns an empty string

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question