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


PHP StringHelper::generateRandomString方法代码示例

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


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

示例1: getUrlUploadSingleImage

 public static function getUrlUploadSingleImage($obj, $user_id)
 {
     $ext_arr = array('png', 'jpg', 'jpeg', 'bmp');
     $name = StringHelper::filterString($obj['name']);
     $storeFolder = Yii::getPathOfAlias('webroot') . '/images/' . date('Y-m-d', time()) . '/' . $user_id . '/';
     if (!file_exists($storeFolder)) {
         mkdir($storeFolder, 0777, true);
     }
     $tempFile = $obj['tmp_name'];
     $ext = strtolower(pathinfo($name, PATHINFO_EXTENSION));
     $random_string = StringHelper::generateRandomString(15);
     $targetFile = $storeFolder . time() . $random_string . '.' . $ext;
     $pathUrl = 'images/' . date('Y-m-d', time()) . '/' . $user_id . '/' . time() . $random_string . '.' . $ext;
     if (in_array($ext, $ext_arr)) {
         if (move_uploaded_file($tempFile, $targetFile)) {
             //  ImageResize::resize_image($pathUrl, '', 1400, 470);
             return $pathUrl;
         } else {
             return NULL;
         }
     } else {
         return NULL;
     }
 }
开发者ID:huynt57,项目名称:quizder,代码行数:24,代码来源:UploadHelper.php

示例2: date

    <div class="container-fluid">
        <div class="navbar-header">
            <h3>SancSoft Task Manager</h3>
        </div>
    </div>
</nav>

<div class="panel panel-primary sanctm-panel">
    <div class="panel-heading">Add a Task</div>
    <div class="panel-body">
        <form id="task-form" method="POST">
            <div class="form-group">
                <label for="input-title">Title</label>
                <input name="title" type="text" class="form-control" id="input-title" placeholder="Title"
                       value="<?php 
echo $stringHelper->generateRandomString();
?>
">
            </div>
            <div class="form-group">
                <label for="input-description">Description</label>
                <textarea name="desc" class="form-control" id="input-description" placeholder="Description"><?php 
echo $stringHelper->generateRandomString();
?>
</textarea>
            </div>
            <div class="form-group">
                <label for="input-duedate">Due Date</label>
                <input name="due_date" type="date" id="input-duedate" value="<?php 
echo date('Y-m-d');
?>
开发者ID:hsupunw,项目名称:FYPSandbox,代码行数:31,代码来源:taskmanager.php

示例3: actionActivate

 public function actionActivate()
 {
     $request = Yii::app()->request;
     try {
         $token = StringHelper::filterString($request->getQuery('token'));
         if ($token != '') {
             $check = Provider::model()->findByAttributes(array('token' => $token));
             if ($check) {
                 $password = StringHelper::generateRandomString(5);
                 $check->token = '';
                 $check->password = md5($password);
                 $check->save('FALSE');
                 $subject = 'Mật khẩu tài khoản provider Meboo của bạn';
                 $to_email = $check->email;
                 $from_email = 'hotro@meboo.vn';
                 $from_name = 'Hỗ trợ Meboo';
                 $message = 'Mật khẩu tài khoản Meboo Provider của bạn: ' . $password;
                 MailQueue::model()->addMailQueue($message, $from_email, $from_name, $to_email, $subject);
                 MailQueue::model()->addMailQueue('Có provider mới', $from_email, $from_name, 'huynt57@gmail.com', 'Có provider mới');
                 Yii::app()->user->setFlash('success', 'Vui lòng kiểm tra email để lấy mật khẩu đăng nhập');
                 $this->redirect(Yii::app()->createUrl('user/login'));
             } else {
                 Yii::app()->user->setFlash('error', 'Token đã hết hạn !');
                 $this->redirect(Yii::app()->createUrl('user/login'));
             }
         } else {
             Yii::app()->user->setFlash('error', 'Token không tồn tại');
             $this->redirect(Yii::app()->createUrl('user/login'));
         }
     } catch (Exception $ex) {
         ResponseHelper::JsonReturnError($ex->getMessage(), 'Error');
     }
 }
开发者ID:huynt57,项目名称:medlatec,代码行数:33,代码来源:UserController.php


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