S
S
Sergey2015-11-06 03:49:18
linux
Sergey, 2015-11-06 03:49:18

What can I replace \r\n\ with in php or how to detect a carriage return in linux?

Hello gentlemen, here is the file disk2.
When I write manually, the kvm server starts without problems.
If I create a file via php, then the kvm server does not start.
Moreover, if you do cat disk2 created manually or through php, then it displays the same thing in the console:
6d9eda10889b4faf9332c60d675c4962.png
php code:

$file = $_SERVER["DOCUMENT_ROOT"].'/base/tmp/disk'.$i;
$fp = fopen($file, "w"); 
$mytext = "KVM_VM_DISK_$i=\"$devicename\"\r\nKVM_VM_DISK_SIZE_$i=\"$sizes[$key]\"\r\n";
$test = fwrite($fp, $mytext);

I think that the carriage return character, which in php is \r\n, does not pass validation.
What can I do? How to solve this problem?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
R
Roman Bulgakov, 2015-11-06
@butteff

in PHP there is a constant PHP_EOL - the string value of the carriage return for the platform on which the code works.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question