-1

i have php script where i write result to file through file_put_content but it not writing for one variable...when i give static value it is working. my code is.

<?php
$uuid = trim(str_replace(' ', '', $dmid));
$establish = "\n\n START -- ".date('Y-m-d h:i:s')." serial-no:".$uuid.",if:".$res_value['if']."\n";
file_put_contents('filter.log', $establish);
?>

when I echo $uuid it displays 03000200-0400-0500-0006-000700080009 but it write on filter.log file like START -- 2017-09-26 06:06:24 serial-no:,if:em1 i tried trim function not any help...i don't how to done this please help me.

Vladyslav
  • 2,018
  • 4
  • 18
  • 44
Divyesh Jesadiya
  • 1,105
  • 4
  • 30
  • 68

1 Answers1

0

When are you echoing $uuid?
The syntax looks good to me but you can try another syntax. The difference below is that the variables are in-line and not concatenated. You can do this with php as long as you use double-quotes. Also, the curly brackets are not necessary but if you use them they guarantee the variables name. see: When to wrap curly braces around a variable :

<?php
$uuid = trim(str_replace(' ', '', $dmid));
$now = date('Y-m-d h:i:s');
echo $uuid;
$establish = "\n\n START -- {$now} serial-no: {$uuid},if:{$res_value['if']}\n";
file_put_contents('filter.log', $establish);
?>