字符串文字前面的b有什么作用? [英] What does the b in front of string literals do?

查看:289
本文介绍了字符串文字前面的b有什么作用?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

$binary = b'Binary string';

b inary形式创建字符串有什么后果?

What consequences does it have to create a string as binary?

我在文档中找不到关于此的任何提示.刚刚在查看language_scanner时发现了这种好奇心.

I couldn't find any hint about that in the documentation. Just found this little curiosity while looking through the language_scanner.

推荐答案

这是永不发布的PHP版本6的前向兼容性令牌,该版本应该具有本机unicode支持.

This is a forward compatibility token for the never-to-be-released PHP version 6, which should have had native unicode support.

在PHP6中,字符串默认为unicode,并且函数在其上的unicode字符级别上运行. "b"表示二进制字符串",即非Unicode字符串,其功能在字节级别上运行.

In PHP6, strings are unicode by default, and functions operate at the unicode character level on them. This "b" means "binary string", that is, a non unicode string, on which functions operate at the byte level.

这在PHP!= 6(所有字符串均为二进制)中无效.

This has no effect in PHP != 6, where all strings are binary.

这篇关于字符串文字前面的b有什么作用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆