zoukankan      html  css  js  c++  java
  • PHP中的src32

    crc32() 函数计算一个字符串的 crc32 多项式。

    该函数可用于验证数据的完整性。

    语法

    crc32(str
    参数描述
    string 必需。规定要计算的字符串。

    说明

    生成 string 参数的 32 位循环冗余校验码多项式。这通常用于检查传输的数据是否完整。

    提示和注释

    提示:由于 PHP 的整数是带符号的,许多 crc32 校验码将返回负整数,因此您需要使用 sprintf() 或 printf() 的 "%u" 格式符来获取表示无符号 crc32 校验码的字符串。

    例子

    例子 1

    在本例中,我们将在使用以及不使用 "%u" 格式符的情况下,输出 crc32() 的结果(注意结果是相同的):

    <?php
    $str = crc32("Hello world!");
    echo 'Without %u: '.$str."<br />";
    echo 'With %u: ';
    printf("%u",$str);
    ?>

    输出:

    Without %u: 461707669
    With %u: 461707669

    例子 2

    在本例中,我们将在使用以及不使用 "%u" 格式符的情况下,输出 crc32() 的结果(注意结果是不相同的):

    <?php
    $str = crc32("Hello world.");
    echo 'Without %u: '.$str."<br />";
    echo 'With %u: ';
    printf("%u",$str);
    ?> 

    输出:

    Without %u: -1959132156
    With %u: 2335835140
  • 相关阅读:
    Nginx 反向代理接收用户包体方式
    Nginx http反向代理流程Proxy_pass模块
    Nginx 负载均衡一致性算法
    Nginx 负载均衡哈希算法:ip_hash与hash模块
    Nginx upstream模块
    Nginx upstream变量
    Nginx 反向代理与负载均衡基本原则
    19 浏览器缓存
    6 Cookie和Session
    5 Post和Get
  • 原文地址:https://www.cnblogs.com/kongqueling/p/php_src32.html
Copyright © 2011-2022 走看看