當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。