本文整理汇总了PHP中CString::equalsCi方法的典型用法代码示例。如果您正苦于以下问题:PHP CString::equalsCi方法的具体用法?PHP CString::equalsCi怎么用?PHP CString::equalsCi使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CString
的用法示例。
在下文中一共展示了CString::equalsCi方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: isSecure
/**
* Determines if the request was sent over an encrypted connection, such as HTTPS.
*
* @return bool `true` if the request was sent over an encrypted connection, `false` otherwise.
*/
public static function isSecure()
{
if (CMap::hasKey($_SERVER, "HTTPS")) {
$value = $_SERVER["HTTPS"];
if (isset($value)) {
return !CString::isEmpty($value) && !CString::equalsCi($value, "off");
}
}
return false;
}
示例2: equals
/**
* Determines if a locale is equal to another locale, comparing them by normalized names.
*
* @param CULocale $toLocale The second locale for comparison.
*
* @return bool `true` if *this* locale is equal to the second locale, `false` otherwise.
*/
public function equals($toLocale)
{
// Parameter type hinting is not used for the purpose of interface compatibility.
assert('is_culocale($toLocale)', vs(isset($this), get_defined_vars()));
return CString::equalsCi($this->m_name, $toLocale->m_name);
}
示例3: leaveNode
public function leaveNode(PhpParser\Node $node)
{
if ($node instanceof PhpParser\Node\Stmt\Class_ || $node instanceof PhpParser\Node\Stmt\Trait_) {
$this->m_numEnteredClassesOrTraits--;
} else {
if ($node instanceof PhpParser\Node\Stmt\Interface_) {
$this->m_numEnteredInterfaces--;
} else {
if ($node instanceof PhpParser\Node\Stmt\ClassMethod) {
$numEnteredMethods = $this->m_numEnteredMethods;
$this->m_numEnteredMethods--;
if (!($this->m_numEnteredClassesOrTraits == 1 && $this->m_numEnteredInterfaces == 0 && $numEnteredMethods == 1 && $this->m_numEnteredClosures == 0 && $this->m_numEnteredFunctions == 0)) {
return;
}
$method = $node;
if (CString::equalsCi($method->name, "__get") && CMap::length($method->params) >= 1) {
$statements = CMap::make();
$len = CArray::length($this->m_propsToWrap);
for ($i = 0; $i < $len; $i++) {
$propName = $this->m_propsToWrap[$i];
$subCondition = new PhpParser\Node\Expr\BooleanNot(new PhpParser\Node\Expr\FuncCall(new PhpParser\Node\Name(self::$ms_isFwCallFuncName)));
$subIf;
if (!$method->byRef) {
$return0 = new PhpParser\Node\Stmt\Return_(new PhpParser\Node\Expr\PropertyFetch(new PhpParser\Node\Expr\Variable("this"), $propName));
$return1 = new PhpParser\Node\Stmt\Return_(new PhpParser\Node\Expr\FuncCall(new PhpParser\Node\Name(self::$ms_toOopFuncName), [new PhpParser\Node\Expr\PropertyFetch(new PhpParser\Node\Expr\Variable("this"), $propName)]));
$else = new PhpParser\Node\Stmt\Else_([$return1]);
$subIf = new PhpParser\Node\Stmt\If_($subCondition, ["stmts" => [$return0], "else" => $else]);
} else {
$subStatements0 = CMap::make();
$return = new PhpParser\Node\Stmt\Return_(new PhpParser\Node\Expr\PropertyFetch(new PhpParser\Node\Expr\Variable("this"), $propName));
CMap::insertValue($subStatements0, $return);
$subStatements1 = CMap::make();
$assignment = new PhpParser\Node\Expr\Assign(new PhpParser\Node\Expr\ArrayDimFetch(new PhpParser\Node\Expr\Variable("GLOBALS"), new PhpParser\Node\Scalar\String(self::$ms_byRefGVarName)), new PhpParser\Node\Expr\FuncCall(new PhpParser\Node\Name(self::$ms_toOopFuncName), [new PhpParser\Node\Expr\PropertyFetch(new PhpParser\Node\Expr\Variable("this"), $propName)]));
CMap::insertValue($subStatements1, $assignment);
$return = new PhpParser\Node\Stmt\Return_(new PhpParser\Node\Expr\ArrayDimFetch(new PhpParser\Node\Expr\Variable("GLOBALS"), new PhpParser\Node\Scalar\String(self::$ms_byRefGVarName)));
CMap::insertValue($subStatements1, $return);
$else = new PhpParser\Node\Stmt\Else_($subStatements1);
$subIf = new PhpParser\Node\Stmt\If_($subCondition, ["stmts" => $subStatements0, "else" => $else]);
}
$condition = new PhpParser\Node\Expr\BinaryOp\Identical(new PhpParser\Node\Expr\Variable($method->params[0]->name), new PhpParser\Node\Scalar\String($propName));
$if = new PhpParser\Node\Stmt\If_($condition, ["stmts" => [$subIf]]);
CMap::insertValue($statements, $if);
}
if (isset($method->stmts)) {
foreach ($method->stmts as $stmt) {
CMap::insertValue($statements, $stmt);
}
}
$method->stmts = $statements;
return $method;
} else {
if (CString::equalsCi($method->name, "__set") && CMap::length($method->params) >= 2) {
$statements = CMap::make();
$len = CArray::length($this->m_propsToWrap);
for ($i = 0; $i < $len; $i++) {
$propName = $this->m_propsToWrap[$i];
$subCondition = new PhpParser\Node\Expr\BooleanNot(new PhpParser\Node\Expr\FuncCall(new PhpParser\Node\Name(self::$ms_isFwCallFuncName)));
$assignment0 = new PhpParser\Node\Expr\Assign(new PhpParser\Node\Expr\PropertyFetch(new PhpParser\Node\Expr\Variable("this"), $propName), new PhpParser\Node\Expr\Variable($method->params[1]->name));
$assignment1 = new PhpParser\Node\Expr\Assign(new PhpParser\Node\Expr\PropertyFetch(new PhpParser\Node\Expr\Variable("this"), $propName), new PhpParser\Node\Expr\FuncCall(new PhpParser\Node\Name(self::$ms_fromOopFuncName), [new PhpParser\Node\Expr\Variable($method->params[1]->name)]));
$else = new PhpParser\Node\Stmt\Else_([$assignment1]);
$subIf = new PhpParser\Node\Stmt\If_($subCondition, ["stmts" => [$assignment0], "else" => $else]);
$condition = new PhpParser\Node\Expr\BinaryOp\Identical(new PhpParser\Node\Expr\Variable($method->params[0]->name), new PhpParser\Node\Scalar\String($propName));
$if = new PhpParser\Node\Stmt\If_($condition, ["stmts" => [$subIf]]);
CMap::insertValue($statements, $if);
}
if (isset($method->stmts)) {
foreach ($method->stmts as $stmt) {
CMap::insertValue($statements, $stmt);
}
}
$method->stmts = $statements;
return $method;
}
}
} else {
if ($node instanceof PhpParser\Node\Expr\Closure) {
$this->m_numEnteredClosures--;
} else {
if ($node instanceof PhpParser\Node\Stmt\Function_) {
$this->m_numEnteredFunctions--;
}
}
}
}
}
}
示例4: toBoolFromOo
/**
* Converts a string into a boolean value, as `true` for "on" and as `false` for "off" or any other string.
*
* The conversion is case-insensitive.
*
* @param string $string The string to be converted.
*
* @return bool `true` for "on", `false` for any other string.
*/
public static function toBoolFromOo($string)
{
assert('is_cstring($string)', vs(isset($this), get_defined_vars()));
return CString::equalsCi($string, "on");
}
示例5: addHeaderWithoutOverriding
protected function addHeaderWithoutOverriding($headers, $headerName, $value)
{
$headerLine;
$headerName = CString::trim($headerName);
$value = CString::trim($value);
$foundHeaderPos;
$alreadyExists = CArray::find($headers, $headerName, function ($element0, $element1) {
return CRegex::find($element0, "/^\\h*" . CRegex::enterTd($element1) . "\\h*:/i");
}, $foundHeaderPos);
if (!$alreadyExists) {
$headerLine = "{$headerName}: {$value}";
} else {
// The header already exists. Combine the header values, removing duplicates based on case-insensitive
// equality.
$currValue = CRegex::remove($headers[$foundHeaderPos], "/^.*?:\\h*/");
CArray::remove($headers, $foundHeaderPos);
$values = CString::split("{$currValue}, {$value}", ",");
$len = CArray::length($values);
for ($i = 0; $i < $len; $i++) {
$values[$i] = CString::trim($values[$i]);
}
$values = CArray::filter($values, function ($element) {
return !CString::isEmpty($element);
});
$values = CArray::unique($values, function ($element0, $element1) {
return CString::equalsCi($element0, $element1);
});
$combinedValue = CArray::join($values, ", ");
$headerLine = "{$headerName}: {$combinedValue}";
}
CArray::push($headers, $headerLine);
}
示例6: toBoolFromOo
/**
* Converts a string into a boolean value, as `true` for "on" and as `false` for "off" or any other string.
*
* The conversion is case-insensitive.
*
* @return bool `true` for "on", `false` for any other string.
*/
public function toBoolFromOo()
{
return CString::equalsCi($this, "on");
}
示例7: filter
/**
* Filters a string or a collection of strings according to the expected output type(s) and returns the output
* value(s).
*
* @param mixed $inputStringOrDecodedCollection The string to be filtered or the array or map containing the
* strings to be filtered. If the parameter's value is a JSON-encoded string, the output value is going to be
* either an array or map.
* @param reference $success **OUTPUT.** After the method is called, the value of this parameter tells whether
* the filtering was successful.
*
* @return mixed The output value or a collection of values of the expected type(s) after having been put through
* the filter.
*/
public function filter($inputStringOrDecodedCollection, &$success)
{
assert('is_cstring($inputStringOrDecodedCollection) || is_collection($inputStringOrDecodedCollection)', vs(isset($this), get_defined_vars()));
$success = true;
if ($this->m_expectedType != self::CARRAY && $this->m_expectedType != self::CMAP) {
// The expected output type is not a collection; the input value must be of string type.
if (!is_cstring($inputStringOrDecodedCollection)) {
$success = false;
return oop_x($this->m_defaultValue);
}
$inputString = $inputStringOrDecodedCollection;
if ($this->m_expectedType == self::BOOL || $this->m_expectedType == self::INT || $this->m_expectedType == self::FLOAT || $this->m_expectedType == self::EMAIL || $this->m_expectedType == self::URL || $this->m_expectedType == self::IP) {
// Trim the input string on both sides from whitespace, including Unicode whitespace and control
// characters.
$trimmingSubjectRe = CUString::TRIMMING_AND_SPACING_NORM_SUBJECT_RE;
$inputString = CRegex::remove($inputString, "/^({$trimmingSubjectRe})+|({$trimmingSubjectRe})+\\z/u");
}
// Pre-process the string for integer and floating-point types.
$looksLikeHex;
if ($this->m_expectedType == self::INT || $this->m_expectedType == self::FLOAT) {
if (CString::startsWith($inputString, "+")) {
// Remove the plus sign.
$inputString = CString::substr($inputString, 1);
}
$looksLikeHex = CRegex::find($inputString, "/^-?0x/i");
if ($this->m_allowLeadingZeros && !($this->m_expectedType == self::INT && $this->m_allowHex && $looksLikeHex)) {
// Remove any leading zeros (except for special cases).
$inputString = CRegex::replace($inputString, "/^(\\D*)0*(?!\\b)/", "\$1");
}
if ($this->m_allowComma) {
$inputString = CRegex::remove($inputString, "/,(?=\\d{3}\\b)/");
}
}
// Validate and sanitize the value according to its expected type.
if ($this->m_expectedType == self::BOOL) {
if (!CRegex::find($inputString, "/^(1|true|yes|on|0|false|no|off)\\z/i")) {
$success = false;
return $this->m_defaultValue;
}
return CString::equals($inputString, "1") || CString::equalsCi($inputString, "true") || CString::equalsCi($inputString, "yes") || CString::equalsCi($inputString, "on");
}
if ($this->m_expectedType == self::INT) {
$value;
if (!($this->m_allowHex && $looksLikeHex)) {
// Regular.
if (!CRegex::find($inputString, "/^-?(?!0(?!\\b))\\d+\\z/")) {
$success = false;
return $this->m_defaultValue;
}
$value = CString::toInt($inputString);
} else {
// Hex.
if (!CRegex::find($inputString, "/^-?0x[0-9A-F]+\\z/i")) {
$success = false;
return $this->m_defaultValue;
}
$value = CString::toIntFromHex($inputString);
}
if (isset($this->m_intValidMin) && $value < $this->m_intValidMin || isset($this->m_intValidMax) && $value > $this->m_intValidMax) {
$success = false;
return $this->m_defaultValue;
}
if (isset($this->m_intClampingMin) && $value < $this->m_intClampingMin) {
$value = $this->m_intClampingMin;
}
if (isset($this->m_intClampingMax) && $value > $this->m_intClampingMax) {
$value = $this->m_intClampingMax;
}
return $value;
}
if ($this->m_expectedType == self::FLOAT) {
if (!CRegex::find($inputString, "/^-?(?!0(?!\\b))\\d*\\.?\\d+(e[\\-+]?\\d+)?\\z/i")) {
$success = false;
return $this->m_defaultValue;
}
$value = CString::toFloat($inputString);
if (isset($this->m_floatValidMin) && $value < $this->m_floatValidMin || isset($this->m_floatValidMax) && $value > $this->m_floatValidMax) {
$success = false;
return $this->m_defaultValue;
}
if (isset($this->m_floatClampingMin) && $value < $this->m_floatClampingMin) {
$value = $this->m_floatClampingMin;
}
if (isset($this->m_floatClampingMax) && $value > $this->m_floatClampingMax) {
$value = $this->m_floatClampingMax;
}
return $value;
//.........这里部分代码省略.........