Nev Posted July 2, 2013 Share Posted July 2, 2013 Hi all, I hope some one can shed some light for me as how to send a carriage return and newline inside a spring that is being sent to a serialport. then read back to browser. The new lines are not working. I've tried \n \r \r\n <br> PHP_EOL. I can get this to work via the echo command but not when sending the spring via serial port. Thanks in anticipation. $serial->sendMessage("The big Brown Fox jumped over the cold lazey dog") . "<br>"; $serial->sendMessage("Message 2"); // Or to read from $read = $serial->readPort(); echo $read; echo "line 1" . "<br>"; echo "line 2" . "<br>"; echo "line 3" . "<br>"; I get the Result below. The big Brown Fox jumped over the cold lazey dogMessage 2line 1line 2line 3 Quote Link to comment https://forums.phpfreaks.com/topic/279779-newline-carriage-return-in-string/ Share on other sites More sharing options...
PravinS Posted July 2, 2013 Share Posted July 2, 2013 try using like this $serial->sendMessage("The big Brown Fox jumped over the cold lazey dog <br>"); Quote Link to comment https://forums.phpfreaks.com/topic/279779-newline-carriage-return-in-string/#findComment-1439014 Share on other sites More sharing options...
JonnoTheDev Posted July 2, 2013 Share Posted July 2, 2013 $serial->sendMessage("The big Brown Fox jumped over the cold lazy dog\n") ; $serial->sendMessage("Message 2\n"); // Or to read from $read = $serial->readPort(); echo nl2br($read); echo "line 1" . "<br>"; echo "line 2" . "<br>"; echo "line 3" . "<br>"; Quote Link to comment https://forums.phpfreaks.com/topic/279779-newline-carriage-return-in-string/#findComment-1439040 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.