当前位置: 首页>>代码示例>>PHP>>正文


PHP PSU::randomString方法代码示例

本文整理汇总了PHP中PSU::randomString方法的典型用法代码示例。如果您正苦于以下问题:PHP PSU::randomString方法的具体用法?PHP PSU::randomString怎么用?PHP PSU::randomString使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在PSU的用法示例。


在下文中一共展示了PSU::randomString方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: testRandomString

 function testRandomString()
 {
     $this->assertEquals(preg_match('/^[A-Za-z0-9]{8}$/', PSU::randomString(8)), 1, 'Length test: 8');
     $this->assertEquals(preg_match('/^[A-Za-z0-9]{20}$/', PSU::randomString(20)), 1, 'Length test: 20');
     $this->assertEquals(preg_match('/^[0-9]{20}$/', PSU::randomString(20, '0123456789')), 1, 'Pattern test (numbers)');
     $this->assertEquals(preg_match('/^A{20}$/', PSU::randomString(20, 'A')), 1, 'Pattern test (letter A)');
     $s = PSU::randomString(62, null, false);
     $len = strlen($s);
     $found = array();
     for ($i = 0; $i < $len; $i++) {
         $c = $s[$i];
         $found[$c] = true;
     }
     $this->assertTrue(count($found) === 62, 'no duplicates');
 }
开发者ID:AholibamaSI,项目名称:plymouth-webapp,代码行数:15,代码来源:MiscTest.php

示例2: insertSABNSTU

 /**
  * insert id/pin data
  */
 public function insertSABNSTU()
 {
     // insert sabnstu data
     // use commonapplicationClientID as the SABNSTU_ID
     // generate a random pin using PSUTools
     // first check sabiden to see if person already has an application
     $aidm = $this->checkSABIDEN($this->commonapplicantclientid);
     if ($aidm) {
         psu::puke("This person, Client ID: " . $this->commonapplicantclientid . " is already in sabiden.");
     }
     if (!$aidm) {
         $aidm = PSU::db('banner')->GetOne("SELECT sabaseq.nextval FROM dual");
     }
     $pin = PSU::randomString(6, "1234567890");
     $client_id = $this->commonapplicantclientid;
     $sql = "INSERT INTO sabnstu (\n\t\t\t\t\t\t\t\tsabnstu_id,\n\t\t\t\t\t\t\t\tsabnstu_aidm,\n\t\t\t\t\t\t\t\tsabnstu_locked_ind,\n\t\t\t\t\t\t\t\tsabnstu_pin,\n\t\t\t\t\t\t\t\tsabnstu_activity_date\n\t\t\t\t\t\t\t) VALUES (\n\t\t\t\t\t\t\t\tlpad(:client_id,9,'0'),\n\t\t\t\t\t\t\t\t:aidm,\n\t\t\t\t\t\t\t\t'N',\n\t\t\t\t\t\t\t\t:pin,\n\t\t\t\t\t\t\t\tsysdate\n\t\t\t\t\t\t\t)";
     $rs = PSU::db('banner')->Execute($sql, compact('client_id', 'aidm', 'pin'));
     if ($rs) {
         $successfully_moved_to_banner = true;
     } else {
         $successfully_moved_to_banner = false;
         psu::puke($client_id . " Failed trying to insert into Banner table SABNSTU.");
     }
     return $successfully_moved_to_banner;
 }
开发者ID:AholibamaSI,项目名称:plymouth-webapp,代码行数:28,代码来源:CommonAppRecord.class.php


注:本文中的PSU::randomString方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。