本文整理汇总了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;
}