[英]PHP equivalent of VB.net character codes
So I am calling an API written in VB.NET from PHP and passing it some text. 因此,我正在从PHP调用用VB.NET编写的API,并将其传递一些文本。 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)
. 我了解在VB.NET中,换行符的字符代码是
Chr(10)
和Chr(13)
。 How can I represent those in PHP? 如何用PHP表示那些?
TIA. TIA。
The chr function exists in PHP too. chr函数也存在于PHP中。
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) 但是,通常,我们使用“
\\n
”(换行符; chr = 10)和“ \\r
”(回车符; chr = 13) (请注意双引号-在此处不要使用简单的引号,因为您需要这些字符)
For more informations, and a list of the escape sequences for special characters, you can take a look at the manual page about strings . 有关更多信息,以及特殊字符的转义序列的列表,您可以查看有关字符串的手册页 。
eg 例如
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: 使用PHP
chr()
函数,这看起来可能更熟悉,但是您几乎不会看到它是这样的:
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. 还有一个名为PHP_EOL的常量,其中包含最适合运行PHP的系统的换行顺序 。
$ break =“ \\ n”;
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.