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


PHP TextCleaner::stripslashes方法代码示例

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


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

示例1: cleanVars

 /**
  * clean values of all variables of the object for storage. 
  * also add slashes whereever needed
  * 
  * @return bool true if successful
  * @access public
  */
 public function cleanVars()
 {
     $ts =& TextCleaner::getInstance();
     $existing_errors = $this->getErrors();
     $this->_errors = array();
     foreach ($this->vars as $k => $v) {
         $cleanv = $v['value'];
         if (!$v['changed']) {
         } else {
             $cleanv = is_string($cleanv) ? trim($cleanv) : $cleanv;
             switch ($v['data_type']) {
                 case XOBJ_DTYPE_TXTBOX:
                     if ($v['required'] && $cleanv != '0' && $cleanv == '') {
                         $this->setErrors(sprintf(_XOBJ_ERR_REQUIRED, $k));
                         continue;
                     }
                     if (isset($v['maxlength']) && strlen($cleanv) > intval($v['maxlength'])) {
                         $this->setErrors(sprintf(_XOBJ_ERR_SHORTERTHAN, $k, intval($v['maxlength'])));
                         continue;
                     }
                     $cleanv = TextCleaner::stripslashes($cleanv);
                     break;
                 case XOBJ_DTYPE_TXTAREA:
                     if ($v['required'] && $cleanv != '0' && $cleanv == '') {
                         $this->setErrors(sprintf(_XOBJ_ERR_REQUIRED, $k));
                         continue;
                     }
                     $cleanv = TextCleaner::stripslashes($cleanv);
                     break;
                 case XOBJ_DTYPE_SOURCE:
                     $cleanv = TextCleaner::stripslashes($cleanv);
                     break;
                 case XOBJ_DTYPE_INT:
                     $cleanv = intval($cleanv);
                     break;
                 case XOBJ_DTYPE_EMAIL:
                     if ($v['required'] && $cleanv == '') {
                         $this->setErrors(sprintf(_XOBJ_ERR_REQUIRED, $k));
                         continue;
                     }
                     if ($cleanv != '' && !preg_match("/^[_a-z0-9-]+(\\.[_a-z0-9-]+)*@[a-z0-9-]+([\\.][a-z0-9-]+)+\$/i", $cleanv)) {
                         $this->setErrors("Invalid Email");
                         continue;
                     }
                     $cleanv = TextCleaner::stripslashes($cleanv);
                     break;
                 case XOBJ_DTYPE_URL:
                     if ($v['required'] && $cleanv == '') {
                         $this->setErrors(sprintf(_XOBJ_ERR_REQUIRED, $k));
                         continue;
                     }
                     if ($cleanv != '' && !preg_match("/^http[s]*:\\/\\//i", $cleanv)) {
                         $cleanv = 'http://' . $cleanv;
                     }
                     $cleanv = TextCleaner::stripslashes($cleanv);
                     break;
                 case XOBJ_DTYPE_ARRAY:
                     $cleanv = !empty($cleanv) && is_array($cleanv) ? serialize($cleanv) : $cleanv;
                     break;
                 case XOBJ_DTYPE_STIME:
                 case XOBJ_DTYPE_MTIME:
                 case XOBJ_DTYPE_LTIME:
                     $cleanv = !is_string($cleanv) ? intval($cleanv) : strtotime($cleanv);
                     break;
                 default:
                     break;
             }
         }
         $this->cleanVars[$k] =& $cleanv;
         unset($cleanv);
     }
     if (count($this->_errors) > 0) {
         $this->_errors = array_merge($existing_errors, $this->_errors);
         return false;
     }
     $this->_errors = array_merge($existing_errors, $this->_errors);
     $this->unsetDirty();
     return true;
 }
开发者ID:laiello,项目名称:bitcero-modules,代码行数:86,代码来源:object.php


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