本文整理匯總了PHP中StringUtils::trimOnce方法的典型用法代碼示例。如果您正苦於以下問題:PHP StringUtils::trimOnce方法的具體用法?PHP StringUtils::trimOnce怎麽用?PHP StringUtils::trimOnce使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類StringUtils
的用法示例。
在下文中一共展示了StringUtils::trimOnce方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: parseParameterValue
protected function parseParameterValue($value, $locals, $isFinalPass = false)
{
$dataparam = null;
// $deferable = false;
if (substr($value, 0, 1) == '%' && substr($value, -1) == '%' && strpos(substr($value, 1, -1), '%') === false) {
$paramval = 'Data:' . substr($value, 1, -1);
$dataparam = substr($value, 1, -1);
} else {
$paramval = $value;
if (strpos($paramval, 'Data:') === 0) {
$dataparam = substr($paramval, 5);
} elseif (strpos($paramval, 'Global:') === 0) {
$dataparam = substr($paramval, 7);
if (!$isFinalPass) {
throw new DeferralException('Deferred condition due to parameter: ' . $value);
}
//$deferable = true;
}
}
if (strlen($dataparam) >= 3 && strpos($dataparam, '%') !== false) {
$dataparam = $this->parseFormatVariables($dataparam, $locals, $isFinalPass);
}
if ($dataparam != null) {
if (array_key_exists($dataparam, $locals)) {
return $locals[$dataparam];
} elseif (array_key_exists($dataparam, $this->getConstants())) {
return $this->getConstant($dataparam);
} elseif (substr($value, 0, 6) == 'Random') {
return rand(1, intVal(substr($value, 6)));
} elseif (strpos($dataparam, '.') !== false) {
$parts = explode('.', $dataparam);
if (!empty($parts)) {
$broken = true;
$array = $locals;
foreach ($parts as $name) {
if (isset($array[$name])) {
$array = $array[$name];
$broken = false;
} else {
$broken = true;
break;
}
}
if (!$broken) {
return $array;
}
// else if(!$isFinalPass && $deferable) {
// throw new DeferralException('Deferred condition due to parameter: '.$value);
// }
}
}
// elseif(!$isFinalPass && $deferable)
// defer me
// throw new DeferralException('Deferred condition due to parameter: '.$value);
return '';
}
if (count($split = explode('?', $value, 2)) == 2) {
list($method, $args) = $split;
$nvps = explode('&', html_entity_decode($args, ENT_QUOTES));
foreach ($nvps as $param) {
$split = explode('=', $param, 2);
if ($split === FALSE || count($split) == 1) {
throw new Exception('Bad NVP in condition: ' . $value);
}
list($name, $v) = $split;
$params[$name] = $this->parseParameterValue($v, $locals, $isFinalPass);
}
return $this->handleFilter($method, $params, $locals);
}
$val = StringUtils::trimOnce($value, "'");
if (strlen($val) >= 4 && strpos($val, '%') !== false) {
$val = $this->parseFormatVariables($val, $locals, $isFinalPass);
}
return $val;
//return trim_once($value, "'");
}