• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP StringHelper类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: checkOut

 public function checkOut(Request $request)
 {
     $address = \StringHelper::filterString($request->input('address'));
     $name = \StringHelper::filterString($request->input('name'));
     $content = \StringHelper::filterString($request->input('comments'));
     $phone = \StringHelper::filterString($request->input('phone'));
     $count = Cart::count();
     if ($phone != "" && $name != "" && $content != "" && $count > 0) {
         $order = new Order();
         $order->order_name = $name;
         $order->status = 1;
         $order->active = 1;
         $order->order_comment = $content;
         $order->order_address = $address;
         $order->order_phone = $phone;
         $order->save();
         $cart = Cart::content();
         foreach ($cart as $item) {
             $order_detail = new OrderDetail();
             $order_detail->dish_id = $item->id;
             $order_detail->dish_number = $item->qty;
             $order_detail->order_id = $order->id;
             $order_detail->save();
         }
         Cart::destroy();
         return Redirect::to(url('menu'))->with('message', 'Order Success !. You can continue buy now !');
     } else {
         return Redirect::to(url('checkout'))->with('message', 'Order Fail !. Something Wrong !');
     }
 }
开发者ID:huynt57,项目名称:savvy-restaurant,代码行数:30,代码来源:CartController.php


示例2: getUrlUploadMultiImages

 public static function getUrlUploadMultiImages($obj, $user_id)
 {
     $url_arr = array();
     $min_size = 1024 * 1000 * 700;
     $max_size = 1024 * 1000 * 1000 * 3.5;
     foreach ($obj["tmp_name"] as $key => $tmp_name) {
         $ext_arr = array('png', 'jpg', 'jpeg', 'bmp');
         $name = StringHelper::filterString($obj['name'][$key]);
         $storeFolder = Yii::getPathOfAlias('webroot') . '/images/' . date('Y-m-d', time()) . '/' . $user_id . '/';
         $pathUrl = 'images/' . date('Y-m-d', time()) . '/' . $user_id . '/' . time() . $name;
         if (!file_exists($storeFolder)) {
             mkdir($storeFolder, 0777, true);
         }
         $tempFile = $obj['tmp_name'][$key];
         $targetFile = $storeFolder . time() . $name;
         $ext = strtolower(pathinfo($name, PATHINFO_EXTENSION));
         $size = $obj['name']['size'];
         if (in_array($ext, $ext_arr)) {
             if ($size >= $min_size && $size <= $max_size) {
                 if (move_uploaded_file($tempFile, $targetFile)) {
                     array_push($url_arr, $pathUrl);
                 } else {
                     return NULL;
                 }
             } else {
                 return NULL;
             }
         } else {
             return NULL;
         }
     }
     return $url_arr;
 }
开发者ID:huynt57,项目名称:image_chooser,代码行数:33,代码来源:UploadHelper.php


示例3: _makeHandle

 /**
  * Make handle from source name.
  *
  * @param $name
  *
  * @return string
  */
 private function _makeHandle($name, $sourceId)
 {
     // Remove HTML tags
     $handle = preg_replace('/<(.*?)>/', '', $name);
     $handle = preg_replace('/<[\'"‘’“”\\[\\]\\(\\)\\{\\}:]>/', '', $handle);
     $handle = StringHelper::toLowerCase($handle);
     $handle = StringHelper::asciiString($handle);
     $handle = preg_replace('/^[^a-z]+/', '', $handle);
     // In case it was an all non-ASCII handle, have a default.
     if (!$handle) {
         $handle = 'source' . $sourceId;
     }
     $handleParts = preg_split('/[^a-z0-9]+/', $handle);
     $handle = '';
     foreach ($handleParts as $index => &$part) {
         if ($index) {
             $part = ucfirst($part);
         }
         $handle .= $part;
     }
     $appendix = '';
     while (true) {
         $taken = craft()->db->createCommand()->select('handle')->from('assetsources')->where('handle = :handle', array(':handle' => $handle . $appendix))->queryScalar();
         if ($taken) {
             $appendix = (int) $appendix + 1;
         } else {
             break;
         }
     }
     return $handle . $appendix;
 }
开发者ID:jmstan,项目名称:craft-website,代码行数:38,代码来源:m141009_000001_assets_source_handle.php


示例4: actionInsertPostCeleb

 public function actionInsertPostCeleb()
 {
     $this->pageTitile = 'Thêm bài viết người nổi tiếng';
     $request = Yii::app()->request;
     try {
         $post_content = StringHelper::filterString($request->getPost('post_content'));
         $celeb_id = StringHelper::filterString($request->getPost('celeb_id'));
         $location = StringHelper::filterString($request->getPost('location'));
         $cats = $request->getPost('cats');
         if (count($_FILES['images']['tmp_name']) > 1) {
             $url_arr = UploadHelper::getUrlUploadMultiImages($_FILES['images'], $celeb_id . 'celeb');
         } else {
             $url_arr = UploadHelper::getUrlUploadMultiImages($_FILES['images'], $celeb_id . 'celeb');
         }
         // $album = StringHelper::filterString($request->getPost('album'));
         $album = NULL;
         $res = Posts::model()->addPostCeleb($celeb_id, $post_content, $location, $url_arr, $album, $cats);
         if ($res != FALSE) {
             Yii::app()->user->setFlash('success', 'Thêm bài viết thành công');
         } else {
             Yii::app()->user->setFlash('error', 'Có lỗi xảy ra');
         }
         $this->redirect(Yii::app()->createUrl('celebrity/addPost'));
     } catch (Exception $ex) {
         var_dump($ex->getMessage());
     }
 }
开发者ID:huynt57,项目名称:fashion,代码行数:27,代码来源:CelebrityController.php


示例5: generateHandle

 public static function generateHandle($sourceVal)
 {
     // Remove HTML tags
     $handle = preg_replace('/<(.*?)>/', '', $sourceVal);
     // Remove inner-word punctuation
     $handle = preg_replace('/[\'"‘’“”\\[\\]\\(\\)\\{\\}:]/', '', $handle);
     // Make it lowercase
     $handle = strtolower($handle);
     // Convert extended ASCII characters to basic ASCII
     $handle = StringHelper::asciiString($handle);
     // Handle must start with a letter
     $handle = preg_replace('/^[^a-z]+/', '', $handle);
     // Get the "words"
     $words = array_filter(preg_split('/[^a-z0-9]+/', $handle));
     $handle = '';
     // Make it camelCase
     for ($i = 0; $i < count($words); $i++) {
         if ($i == 0) {
             $handle .= $words[$i];
         } else {
             $handle .= strtoupper($words[$i][0]) . substr($words[$i], 1);
         }
     }
     return $handle;
 }
开发者ID:jeremyworboys,项目名称:Formerly,代码行数:25,代码来源:FormerlyHelpers.php


示例6: dispatch

 function dispatch()
 {
     global $ModuleDir, $ClassDir, $template, $DefaultModule, $DefaultPage, $timer;
     $this->path_info = ltrim(getenv("PATH_INFO"), "/");
     $this->setDefualtModule($DefaultModule);
     $this->setDefualtPage($DefaultPage);
     $module_name = $this->getModuleName() ? $this->getModuleName() : $this->getDefualtModule();
     $page_name = $this->getPageName() ? $this->getPageName() : $this->getDefualtPage();
     $action_name = $this->getActionName() ? $this->getActionName() : $this->default_action;
     include_once $ClassDir . "StringHelper.class.php";
     $page_class_name = StringHelper::CamelCaseFromUnderscore($page_name);
     $include_file = $ModuleDir . $module_name . DIRECTORY_SEPARATOR . $page_class_name . ".class.php";
     if (file_exists($include_file)) {
         include_once $include_file;
         $TempObj = new $page_class_name();
         $Action = "execute" . ucfirst($action_name);
         $TempObj->{$Action}();
     }
     //		printf("module %s/ page %s/ action %s/ ",$module_name,$page_name,$action_name);
     //		$template->setFile(array (
     //			"TAB" => "tab.html",
     //		));
     //		$template->setBlock("TAB", "tab");
     $this->parseTemplateLang(true);
     $template->parse("OUT", array("LAOUT"));
     $template->p("OUT");
     if (defined('APF_DEBUG') && APF_DEBUG == true) {
         $timer->stop();
         $timer->display();
     }
 }
开发者ID:BackupTheBerlios,项目名称:flushcms,代码行数:31,代码来源:Controller.class.php


示例7: actionUpdateVersion

 public function actionUpdateVersion()
 {
     $this->retVal = new stdClass();
     $request = Yii::app()->request;
     if ($request->isPostRequest && isset($_POST)) {
         try {
             $app_ver = StringHelper::filterString($request->getPost('app_ver'));
             $db_ver = StringHelper::filterString($request->getPost('db_ver'));
             $model = AppDbVer::model()->findByAttributes(array('id' => 1));
             $model->app_ver = $app_ver;
             $model->db_ver = $db_ver;
             if ($model->save(FALSE)) {
                 $this->retVal->status = 1;
                 $this->retVal->message = "Success";
             } else {
                 $this->retVal->status = 0;
                 $this->retVal->message = "Fail";
             }
             $this->retVal->data = "";
         } catch (exception $e) {
             $this->retVal->message = $e->getMessage();
         }
         echo CJSON::encode($this->retVal);
         Yii::app()->end();
     }
 }
开发者ID:huynt57,项目名称:soyba,代码行数:26,代码来源:VersionController.php


示例8: bookTable

 /**
  * Show the application dashboard to the user.
  *
  * @return Response
  */
 public function bookTable(Request $request)
 {
     $email = \StringHelper::filterString($request->input('email'));
     $name = \StringHelper::filterString($request->input('name'));
     $phone = \StringHelper::filterString($request->input('phone'));
     $number = \StringHelper::filterString($request->input('number'));
     $month = \StringHelper::filterString($request->input('month'));
     $day = \StringHelper::filterString($request->input('day'));
     $hour = \StringHelper::filterString($request->input('hour'));
     $min = \StringHelper::filterString($request->input('min'));
     $a_p = \StringHelper::filterString($request->input('a-p'));
     $content = \StringHelper::filterString($request->input('comments'));
     if ($email != "" && $name != "" && $phone != "" && $number != "" && $month != "" && $day != "") {
         $book_table = new BookTable();
         $book_table->name = $name;
         $book_table->email = $email;
         $book_table->phone = $phone;
         $book_table->number = $number;
         $book_table->comments = $content;
         $book_table->active = 1;
         $book_table->status = 1;
         $book_table->date = $day . "-" . $month . " " . $hour . ":" . $min . " " . $a_p;
         $book_table->save();
     }
     return Redirect::back()->with('message', 'Success');
 }
开发者ID:huynt57,项目名称:savvy-restaurant,代码行数:31,代码来源:ReservationController.php


示例9: actionViewDocument

 public function actionViewDocument()
 {
     if (isset($_GET['doc_id'])) {
         $doc_id = StringHelper::filterString($_GET['doc_id']);
         $detail_doc = Doc::model()->findAll(array("select" => "*", "condition" => "doc_id = :doc_id", "params" => array(':doc_id' => $doc_id)));
         $spCriteria = new CDbCriteria();
         $spCriteria->select = "*";
         $spCriteria->condition = "doc_id = :doc_id";
         $spCriteria->params = array(':doc_id' => $doc_id);
         $subject_doc = SubjectDoc::model()->find($spCriteria);
         $spjCriteria = new CDbCriteria();
         $spjCriteria->select = "*";
         $spjCriteria->condition = "subject_id = :subject_id";
         $spjCriteria->params = array(':subject_id' => $subject_doc->subject_id);
         $subject = Subject::model()->find($spjCriteria);
         $related_doc = Doc::model()->findAll(array("select" => "*", "limit" => "3", "order" => "RAND()"));
         foreach ($detail_doc as $detail) {
             $title = $detail->doc_name . " | Bluebee - UET";
             $this->pageTitle = $title;
             if ($detail->doc_type == 3) {
                 $image = Yii::app()->getBaseUrl(true) . $detail->doc_url;
             } else {
                 $image = $detail->doc_url;
             }
             $des = $detail->doc_description;
             Yii::app()->clientScript->registerMetaTag($title, null, null, array('property' => 'og:title'));
             Yii::app()->clientScript->registerMetaTag($image, null, null, array('property' => 'og:image'));
             Yii::app()->clientScript->registerMetaTag(500, null, null, array('property' => 'og:image:width'));
             Yii::app()->clientScript->registerMetaTag(500, null, null, array('property' => 'og:image:height'));
             Yii::app()->clientScript->registerMetaTag("website", null, null, array('property' => 'og:type'));
             Yii::app()->clientScript->registerMetaTag($des, null, null, array('property' => 'og:description'));
         }
         $this->render('viewDocument', array('detail_doc' => $detail_doc, 'related_doc' => $related_doc, 'subject' => $subject));
     }
 }
开发者ID:huynt57,项目名称:bluebee-uet.com,代码行数:35,代码来源:ViewDocumentController.php


示例10: read

 /**
  * Returns stream only including
  * lines from the original stream which don't start with any of the
  * specified comment prefixes.
  *
  * @param null $len
  * @return mixed the resulting stream, or -1
  *               if the end of the resulting stream has been reached.
  *
  */
 public function read($len = null)
 {
     if (!$this->getInitialized()) {
         $this->_initialize();
         $this->setInitialized(true);
     }
     $buffer = $this->in->read($len);
     if ($buffer === -1) {
         return -1;
     }
     $lines = explode("\n", $buffer);
     $filtered = array();
     $commentsSize = count($this->_comments);
     foreach ($lines as $line) {
         for ($i = 0; $i < $commentsSize; $i++) {
             $comment = $this->_comments[$i]->getValue();
             if (StringHelper::startsWith($comment, ltrim($line))) {
                 $line = null;
                 break;
             }
         }
         if ($line !== null) {
             $filtered[] = $line;
         }
     }
     $filtered_buffer = implode("\n", $filtered);
     return $filtered_buffer;
 }
开发者ID:Ingewikkeld,项目名称:phing,代码行数:38,代码来源:StripLineComments.php


示例11: main

function main()
{
    if ($_SERVER['REQUEST_METHOD'] === 'POST') {
        if (array_key_exists('content', $_POST)) {
            // define password bytes
            $passwordBytes = Configuration::$aesPasswordBytes;
            // decode
            $content = $_POST['content'];
            $decodedContent = base64_decode($content);
            // decrypt
            $decryptedContent = EncryptionHelper::decryptMessage($decodedContent, $passwordBytes);
            $decryptedContent = StringHelper::untilLastOccurence($decryptedContent, '}');
            // json decode
            $highscoreData = json_decode($decryptedContent);
            // store
            $config = ConfidentialConfiguration::getDatabaseConfiguration();
            $highscore = new Highscore($config->databaseHost, $config->databaseUserName, $config->databaseUserPassword, $config->databaseName);
            $highscore->insert($highscoreData);
            die(ResponseHelper::serializeResponse('Success', 'Success'));
        } else {
            die(ResponseHelper::serializeResponse('Error', 'The request must contain a POST parameter'));
        }
    } else {
        die(ResponseHelper::serializeResponse('Error', 'Not a POST request, sorry'));
    }
}
开发者ID:preactor,项目名称:SolarschiffGame,代码行数:26,代码来源:InsertHighscoreEntry.php


示例12: __construct

 public function __construct() {
     parent::__construct();
     $this->fractionDigits = StringHelper::trim($this->numberFormatter->getAttribute(NumberFormatter::FRACTION_DIGITS));
     if ($this->fractionDigits === FALSE) {
         throw new IllegalStateException(t('Cannot detect OS fraction digits'));
     }
 }
开发者ID:reisystems-india,项目名称:GovDashboard-Community,代码行数:7,代码来源:MSSQLExecuteQueryStatementImpl.php


示例13: getInstance

 public static function getInstance()
 {
     if (self::$objInstance == null) {
         self::$objInstance = new StringHelper();
     }
     return self::$objInstance;
 }
开发者ID:lucasmichel,项目名称:cartorioOnline,代码行数:7,代码来源:StringHelper.php


示例14: setPassword

 public function setPassword($pass1, $pass2 = false, $emptyIsOk = false)
 {
     if ($pass1 || $emptyIsOk) {
         // a pass has been set
         if ($pass2 !== false && $pass1 != $pass2) {
             // a confirmation has been set but is different
             $this->_error['password'] = 'user_pass_mismatch';
             return false;
         }
         $this->set('salt', StringHelper::genRandom(8, 'abcdefghijklmnopqrstuvwxyz' . 'ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789'));
         if ($pass1) {
             $arr = explode(',', $this->_properties[$key]);
             $class = array_shift($arr);
             if (VarPss::checkValid($pass1, $arr)) {
                 $this->setRawPassword($pass1, $this->get('salt'));
             } else {
                 $this->_error['password'] = 'user_pass_length';
                 return false;
             }
         } else {
             $this->data['password'] = '';
         }
         return true;
     } else {
         if (!$emptyIsOk) {
             $this->_error['password'] = 'user_pass_empty';
             return false;
         }
         return true;
     }
 }
开发者ID:jaeko44,项目名称:time-tracking,代码行数:31,代码来源:user.php


示例15: init

 /**
  * Initializes the console app by creating the command runner.
  *
  * @return null
  */
 public function init()
 {
     // Set default timezone to UTC
     date_default_timezone_set('UTC');
     // Import all the built-in components
     foreach ($this->componentAliases as $alias) {
         Craft::import($alias);
     }
     // Attach our Craft app behavior.
     $this->attachBehavior('AppBehavior', new AppBehavior());
     // Initialize Cache and LogRouter right away (order is important)
     $this->getComponent('cache');
     $this->getComponent('log');
     // So we can try to translate Yii framework strings
     $this->coreMessages->attachEventHandler('onMissingTranslation', array('Craft\\LocalizationHelper', 'findMissingTranslation'));
     // Set our own custom runtime path.
     $this->setRuntimePath(craft()->path->getRuntimePath());
     // Attach our own custom Logger
     Craft::setLogger(new Logger());
     // No need for these.
     craft()->log->removeRoute('WebLogRoute');
     craft()->log->removeRoute('ProfileLogRoute');
     // Load the plugins
     craft()->plugins->loadPlugins();
     // Validate some basics on the database configuration file.
     craft()->validateDbConfigFile();
     // Call parent::init before the plugin console command logic so craft()->commandRunner will be available to us.
     parent::init();
     foreach (craft()->plugins->getPlugins() as $plugin) {
         $commandsPath = craft()->path->getPluginsPath() . StringHelper::toLowerCase($plugin->getClassHandle()) . '/consolecommands/';
         if (IOHelper::folderExists($commandsPath)) {
             craft()->commandRunner->addCommands(rtrim($commandsPath, '/'));
         }
     }
 }
开发者ID:kentonquatman,项目名称:portfolio,代码行数:40,代码来源:ConsoleApp.php


示例16: __construct

 public function __construct($configuration, $wildcard, $anyCharactersOnLeft = FALSE, $anyCharactersOnRight = FALSE)
 {
     parent::__construct($configuration);
     $this->wildcard = StringHelper::trim($wildcard);
     $this->anyCharactersOnLeft = $anyCharactersOnLeft;
     $this->anyCharactersOnRight = $anyCharactersOnRight;
 }
开发者ID:ecs-hk,项目名称:Checkbook,代码行数:7,代码来源:AbstractWildcardOperatorHandler.php


示例17: counter

 public function counter($requestData)
 {
     $period = isset($requestData['period']) ? $requestData['period'] : null;
     $dimension = isset($requestData['options']['dimension']) ? $requestData['options']['dimension'] : null;
     $metric = isset($requestData['options']['metric']) ? $requestData['options']['metric'] : null;
     $start = date('Y-m-d', strtotime('-1 ' . $period));
     $end = date('Y-m-d');
     // Counter
     $criteria = new Analytics_RequestCriteriaModel();
     $criteria->startDate = $start;
     $criteria->endDate = $end;
     $criteria->metrics = $metric;
     if ($dimension) {
         $optParams = array('filters' => $dimension . '!=(not set);' . $dimension . '!=(not provided)');
         $criteria->optParams = $optParams;
     }
     $response = craft()->analytics->sendRequest($criteria);
     if (!empty($response['rows'][0][0]['f'])) {
         $count = $response['rows'][0][0]['f'];
     } else {
         $count = 0;
     }
     $counter = array('count' => $count, 'label' => StringHelper::toLowerCase(Craft::t(craft()->analytics_metadata->getDimMet($metric))));
     // Return JSON
     return ['type' => 'counter', 'counter' => $counter, 'response' => $response, 'metric' => Craft::t(craft()->analytics_metadata->getDimMet($metric)), 'period' => $period, 'periodLabel' => Craft::t('this ' . $period)];
 }
开发者ID:codeforamerica,项目名称:oakland-beta,代码行数:26,代码来源:Analytics_ReportsService.php


示例18: afterFind

 protected function afterFind()
 {
     if (StringHelper::isNullOrEmpty($this->icon_src)) {
         $this->icon_src = Group::DEFAULT_IMG_PATH;
     }
     return parent::afterFind();
 }
开发者ID:kittolau,项目名称:gcm,代码行数:7,代码来源:Group.php


示例19: processDownload

 /**
  * @return array
  * @throws Exception
  */
 public function processDownload()
 {
     Craft::log('Starting to process the update download.', LogLevel::Info, true);
     $tempPath = craft()->path->getTempPath();
     // Download the package from ET.
     Craft::log('Downloading patch file to ' . $tempPath, LogLevel::Info, true);
     if (($fileName = craft()->et->downloadUpdate($tempPath)) !== false) {
         $downloadFilePath = $tempPath . $fileName;
     } else {
         throw new Exception(Craft::t('There was a problem downloading the package.'));
     }
     $uid = StringHelper::UUID();
     // Validate the downloaded update against ET.
     Craft::log('Validating downloaded update.', LogLevel::Info, true);
     if (!$this->_validateUpdate($downloadFilePath)) {
         throw new Exception(Craft::t('There was a problem validating the downloaded package.'));
     }
     // Unpack the downloaded package.
     Craft::log('Unpacking the downloaded package.', LogLevel::Info, true);
     $unzipFolder = craft()->path->getTempPath() . $uid;
     if (!$this->_unpackPackage($downloadFilePath, $unzipFolder)) {
         throw new Exception(Craft::t('There was a problem unpacking the downloaded package.'));
     }
     return array('uid' => $uid);
 }
开发者ID:kentonquatman,项目名称:portfolio,代码行数:29,代码来源:Updater.php


示例20: deleteOrder

 public function deleteOrder(Request $request)
 {
     $order_id = \StringHelper::filterString($request->input('order_id'));
     $deletedRows = Order::where('id', $order_id)->delete();
     $catRow = OrderDetail::where('order_id', $order_id)->delete();
     return Redirect::back()->with('message', 'Success');
 }
开发者ID:huynt57,项目名称:savvy-restaurant,代码行数:7,代码来源:OrderController.php



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP StringUtil类代码示例发布时间:2022-05-23
下一篇:
PHP StringField类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap