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