Reputation:
The print statements before and after a print statement containing a Carriage return are not working.
<?php
print "hello";
print " hai \r";
print "bro";
?>
the output is
bro
Upvotes: 0
Views: 130
Reputation: 1051
Everything works fine, this symbol is called carriage return and it's used to reset a cursor position.
So what your script is doing:
You see this behaviour only while running a script in console.
The better way to have a new line symbol in your code is to use a special constant PHP_EOL as it will use a proper sequence (\r or \n\r or \n) depending on a running platform.
Upvotes: 1
Reputation: 262
Use
<?php
print "hello";
print " hai \r\n";
print "bro";
?>
For a new line.
Upvotes: 0