小白教程
所有教程
关于
Search
172.71.254.32
172.71.254.32
参数设置
贡献
退出
操作
编辑
移动
保护
信息
历史
删除
查看“Func string crc32”的源代码
本页内容
上一节:
Func_string_count_chars
下一节:
Func_string_crypt
因为以下原因,您没有权限编辑本页:
您请求的操作仅限属于该用户组的用户执行:
用户
您可以查看和复制此页面的源代码。
{{DISPLAYTITLE:crc32()}}[[分类:PHP字符串函数参考手册|11]] = PHP crc32() 函数 = [[:分类:PHP字符串函数参考手册]] 输出 crc32() 的结果: <sample title="" desc="" lang="php" hererun="1"> <?php $str = crc32("Hello World!"); printf("%un",$str); ?> </sample> == 定义和用法 == crc32() 函数计算一个字符串的 32 位 CRC(循环冗余校验)。 该函数可用于验证数据的完整性。 '''提示:'''为确保您能从 crc32() 函数中取得正确的字符串表示,您必须使用 printf() 或 sprintf() 函数的 %u 格式符。如果未使用 %u 格式符,结果可能会显示为不正确的数字或者负数。 == 语法 == crc32(string) {| class="table table-striped table-hover" ! 参数 ! 描述 |- | string | 必需。规定要计算的字符串。 |} == 技术细节 == {| class="table table-striped table-hover" | 返回值: | 以整数形式返回 string 的 32 位循环冗余校验码多项式。 |- | PHP 版本: | 4.0.1+ |} == 实例 1 == 在本实例中,我们将在使用以及不使用 "%u" 格式符的情况下,输出 crc32() 的结果(注意结果是相同的): <sample title="" desc="" lang="php" hererun="1"> <?php $str = crc32("Hello world!"); echo 'Without %u: '.$str."<br>"; echo 'With %u: '; printf("%u",$str); ?> </sample> 上面的代码将输出: <sample title="" desc="" lang="php" hererun="1"> Without %u: 461707669 With %u: 461707669 </sample> == 实例 2 == 在本实例中,我们将在使用以及不使用 "%u" 格式符的情况下,输出 crc32() 的结果(注意结果是不相同的): <sample title="" desc="" lang="php" hererun="1"> <?php $str = crc32("Hello world."); echo 'Without %u: '.$str."<br>"; echo 'With %u: '; printf("%u",$str); ?> </sample> 上面的代码将输出: <sample title="" desc="" lang="php" hererun="1"> Without %u: -1959132156 With %u: 2335835140 </sample> [[:分类:PHP字符串函数参考手册]]
返回至“
Func string crc32
”。
上一节:
Func_string_count_chars
下一节:
Func_string_crypt