php - fgets(STDIN) automatic line break?
477
I noticed something with fgets(STDIN) in php
I have this code :
if($fd = fopen($filename, "a")){
$message = fgets(STDIN);
$message = $message.":";
echo $message;
//fwrite($fd, $message);
fclose($fd);
}
I try for exemple to insert at the end of my text-file :
helloWorld
But i always have :
helloWorld
:
not :
helloWorld:
Is stdin makes a automatic line feed ? How to remove this automatic jump ?
Answer
Solution:
Use stream_get_line instead of fgets:
Or you can use rtrim function to remove line endings: