本文整理匯總了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;
}