tags:

views:

190

answers:

3

Hi,

So I am calling an API written in VB.NET from PHP and passing it some text. I want to insert into that text two linebreaks.

I understand that in VB.NET, the character codes for a linebreak are Chr(10) and Chr(13). How can I represent those in PHP?

TIA.

A: 

$break = "\n";

Mark L
+3  A: 

The chr function exists in PHP too.

But, generally, we use "\n" (newline ; chr=10) and "\r" (carriage-return ; chr=13) (note the double-quotes - do not use simple quotes here, is you want those characters)

For more informations, and a list of the escape sequences for special characters, you can take a look at the manual page about strings.

Pascal MARTIN
Oh...that was easy. Thanks.
benjy
You're welcome! Have fun!
Pascal MARTIN
+2  A: 
  • CR or Carriage Return, Chr(10), is represented by \r in a string
  • LF or Line Feed, Chr(13), is represented by \n in a string

e.g.

echo "This is\r\na broken line";

this might look more familiar, using the PHP chr() function, but you'd rarely see it done like this:

echo "This is".chr(10).chr(13)."a broken line";

There is also a constant called PHP_EOL which contains the most appropriate line break sequence for the system PHP is running on.

Paul Dixon