Blogger Information
Blog 175
fans 1
comment 0
visits 384348
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
CentOS7 SVN安装配置
dxp2tq的博客
Original
1180 people have browsed it

php订单号的生成

来自ECSHOP订单号生成函数:/includes/lib_order.php文件中的get_order_sn()
/**

  • 得到新订单号
  • @return string
    /
    function build_order_no()
    {
    /
    选择一个随机的方案 /
    mt_srand((double) microtime()
    1000000);
    return date(‘Ymd’) . str_pad(mt_rand(1, 99999), 5, ‘0’, STR_PAD_LEFT);
    }

原订单号格式为年月日+5位随机数,例如:2012022112345。如果你想改变订单号的生成规则,可对该函数进行修改,我想让订单号改为 “PHPALLY” + 年月日 + 6位随机数字,那么可以这样修改:

/**

  • 得到新订单号
  • @return string
    /
    function build_order_no()
    {
    /
    选择一个随机的方案 /
    mt_srand((double) microtime()
    1000000);
    / PHPALLY + 年月日 + 6位随机数 /
    return ‘PHPALLY’ . date(‘Ymd’) . str_pad(mt_rand(1, 999999), 6, ‘0’, STR_PAD_LEFT);
    }
Statement of this Website
The copyright of this blog article belongs to the blogger. Please specify the address when reprinting! If there is any infringement or violation of the law, please contact admin@php.cn Report processing!
All comments Speak rationally on civilized internet, please comply with News Comment Service Agreement
0 comments
Author's latest blog post