本文整理匯總了PHP中Inflector::length方法的典型用法代碼示例。如果您正苦於以下問題:PHP Inflector::length方法的具體用法?PHP Inflector::length怎麽用?PHP Inflector::length使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Inflector
的用法示例。
在下文中一共展示了Inflector::length方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: __construct
public function __construct($language, $segment = '')
{
if (Inflector::length($segment)) {
$fileTranslation = LANGUAGE_PATH . DS . ucwords(Inflector::lower(repl('.', DS, $segment))) . DS . Inflector::lower($language) . '.ini';
} else {
$fileTranslation = LANGUAGE_PATH . DS . Inflector::lower($language) . '.ini';
}
if (File::exists($fileTranslation)) {
$ini = new Ini($fileTranslation);
$translations = $ini->parseIni();
$this->setSentences($translations);
Utils::set('ThinTranslate', $this);
} else {
throw new Exception('The translation file ' . $fileTranslation . ' does not exist.');
}
}
示例2: unpad
/**
* Remove the PKCS7 compatible padding from the given value.
*
* @param string $value
* @return string
*/
protected static function unpad($value)
{
$pad = ord($value[($length = Inflector::length($value)) - 1]);
if ($pad and $pad < static::$block) {
// If the correct padding is present on the string, we will remove
// it and return the value. Otherwise, we'll throw an exception
// as the padding appears to have been changed.
if (preg_match('/' . chr($pad) . '{' . $pad . '}$/', $value)) {
return substr($value, 0, $length - $pad);
} else {
throw new Exception("Decryption error. Padding is invalid.");
}
}
return $value;
}