douwen3965 2014-06-08 07:19 采纳率: 0%
浏览 55
已采纳

Laravel代码生成器

I am using Laravel 4 and I am looking for a system to generate simple short alphanumeric codes, kinda like what Steam does when you login from a new machine, they send you an email with some text like this:

Someone has tried to log in into your account from an unknown device. If this is really you, please input this code to authenticate the access:

ZT27K

Thank you

Is there some sort of random, short codes generator in Laravel?

  • 写回答

1条回答 默认 最新

  • doutusheng5879 2014-06-08 07:25
    关注

    Yup! A bit down on the helpers documentation page is the str_random() function, which can be used anywhere like so:

    $string = str_random(5);
    

    (Note: it defaults to 16 if its length argument is left out.)

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
编辑
预览

报告相同问题?

手机看
程序员都在用的中文IT技术交流社区

程序员都在用的中文IT技术交流社区

专业的中文 IT 技术社区,与千万技术人共成长

专业的中文 IT 技术社区,与千万技术人共成长

关注【CSDN】视频号,行业资讯、技术分享精彩不断,直播好礼送不停!

关注【CSDN】视频号,行业资讯、技术分享精彩不断,直播好礼送不停!

客服 返回
顶部