本文整理汇总了PHP中ctype_lower函数的典型用法代码示例。如果您正苦于以下问题:PHP ctype_lower函数的具体用法?PHP ctype_lower怎么用?PHP ctype_lower使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了ctype_lower函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: tk_populate_initial_theme_settings_data
function tk_populate_initial_theme_settings_data()
{
require get_template_directory() . '/config/admin-config.php';
$i = 0;
$last_val = '';
$tab_name = '';
foreach ($tabs as $tab) {
foreach ($tab as $tab1) {
if (!is_array($tab1)) {
if (ctype_lower($tab1)) {
$tab_name = $tab1;
}
// if
}
// check if tab1 is array
foreach ((array) $tab1 as $tab2) {
if (isset($tab2['name']) && isset($tab2['value']) && isset($tab2['type'])) {
if (!empty($tab2['value']) && $tab2['type'] != 'select') {
if (get_option(wp_get_theme()->name . '_' . $tab2['name']) == false) {
update_option(wp_get_theme()->name . '_' . $tab_name . '_' . $tab2['name'], $tab2['value']);
}
// if have name
}
// if have value, type
}
// if have name, valua and type
}
// foreach tab1
}
// foreach tab
}
// foreach tabs
}
示例2: expressionFunction
/**
* Returns Expression function implementation as closure
*
* @return \Closure
*/
public function expressionFunction()
{
return function ($arguments) {
$string = $arguments[0];
return ctype_lower($string);
};
}
示例3: import
/**
* Create and position pieces of the game for the forsyth string
*
* @param Game $game
* @param string $forsyth
* @return Game $game
*/
public static function import(Game $game, $forsyth)
{
static $classes = array('p' => 'Pawn', 'r' => 'Rook', 'n' => 'Knight', 'b' => 'Bishop', 'q' => 'Queen', 'k' => 'King');
$x = 1;
$y = 8;
$board = $game->getBoard();
$forsyth = str_replace('/', '', preg_replace('#\\s*([\\w\\d/]+)\\s.+#i', '$1', $forsyth));
$pieces = array('white' => array(), 'black' => array());
for ($itForsyth = 0, $forsythLen = strlen($forsyth); $itForsyth < $forsythLen; $itForsyth++) {
$letter = $forsyth[$itForsyth];
if (is_numeric($letter)) {
$x += intval($letter);
} else {
$color = ctype_lower($letter) ? 'black' : 'white';
$pieces[$color][] = new Piece($x, $y, $classes[strtolower($letter)]);
++$x;
}
if ($x > 8) {
$x = 1;
--$y;
}
}
foreach ($game->getPlayers() as $player) {
$player->setPieces($pieces[$player->getColor()]);
}
$game->ensureDependencies();
}
示例4: validate
function validate($css, $config, &$context)
{
$css = $this->parseCDATA($css);
$definition = $config->getCSSDefinition();
// we're going to break the spec and explode by semicolons.
// This is because semicolon rarely appears in escaped form
// Doing this is generally flaky but fast
// IT MIGHT APPEAR IN URIs, see HTMLPurifier_AttrDef_CSSURI
// for details
$declarations = explode(';', $css);
$propvalues = array();
foreach ($declarations as $declaration) {
if (!$declaration) {
continue;
}
if (!strpos($declaration, ':')) {
continue;
}
list($property, $value) = explode(':', $declaration, 2);
$property = trim($property);
$value = trim($value);
$ok = false;
do {
if (isset($definition->info[$property])) {
$ok = true;
break;
}
if (ctype_lower($property)) {
break;
}
$property = strtolower($property);
if (isset($definition->info[$property])) {
$ok = true;
break;
}
} while (0);
if (!$ok) {
continue;
}
// inefficient call, since the validator will do this again
if (strtolower(trim($value)) !== 'inherit') {
// inherit works for everything (but only on the base property)
$result = $definition->info[$property]->validate($value, $config, $context);
} else {
$result = 'inherit';
}
if ($result === false) {
continue;
}
$propvalues[$property] = $result;
}
// procedure does not write the new CSS simultaneously, so it's
// slightly inefficient, but it's the only way of getting rid of
// duplicates. Perhaps config to optimize it, but not now.
$new_declarations = '';
foreach ($propvalues as $prop => $value) {
$new_declarations .= "{$prop}:{$value};";
}
return $new_declarations ? $new_declarations : false;
}
示例5: asSnakeCase
public static function asSnakeCase($value)
{
if (!is_string($value)) {
return $value;
}
return ctype_lower($value) ? $value : mb_strtolower(preg_replace('/(.)([A-Z])/', '$1_$2', $value));
}
示例6: init
/**
* Initializes the object depending of the name in Api specifications
*
* @param string $name object name
* @return ApiEntity|DetailsResponse|ListResponse|ObjectEntity|Property
*/
public static function init($name)
{
if (preg_match('#^.*(List|Details)(Response)$#', $name, $match)) {
return $match[1] == 'List' ? new ListResponse($name) : new DetailsResponse($name);
}
return ctype_lower($name[0]) ? new Property($name) : (preg_match('#^Api#', $name) ? new ApiEntity($name) : new ObjectEntity($name));
}
示例7: validate
public function validate($length, $config, $context)
{
$length = $this->parseCDATA($length);
if ($length === '') {
return false;
}
if ($length === '0') {
return '0';
}
$strlen = strlen($length);
if ($strlen === 1) {
return false;
}
// impossible!
// we assume all units are two characters
$unit = substr($length, $strlen - 2);
if (!ctype_lower($unit)) {
$unit = strtolower($unit);
}
$number = substr($length, 0, $strlen - 2);
if (!isset($this->units[$unit])) {
return false;
}
$number = $this->number_def->validate($number, $config, $context);
if ($number === false) {
return false;
}
return $number . $unit;
}
示例8: validate
/**
* Validates the number and unit.
*/
function validate()
{
// Special case:
static $allowedUnits = array('em' => true, 'ex' => true, 'px' => true, 'in' => true, 'cm' => true, 'mm' => true, 'pt' => true, 'pc' => true);
if ($this->n === '+0' || $this->n === '-0') {
$this->n = '0';
}
if ($this->n === '0' && $this->unit === false) {
return true;
}
if (!ctype_lower($this->unit)) {
$this->unit = strtolower($this->unit);
}
if (!isset($allowedUnits[$this->unit])) {
return false;
}
// Hack:
$def = new HTMLPurifier_AttrDef_CSS_Number();
$a = false;
// hack hack
$result = $def->validate($this->n, $a, $a);
if ($result === false) {
return false;
}
$this->n = $result;
return true;
}
示例9: crypto
function crypto($n, $string, $k)
{
$low = range('a', 'z');
$high = range('A', 'Z');
$newLetters = [];
for ($i = 0; $i < $n; $i++) {
$letter = $string[$i];
switch (true) {
case ctype_upper($letter):
$off = offsetK(array_search($letter, $high) + $k);
$new = array_slice($high, $off, 1)[0];
break;
case ctype_lower($letter):
$off = offsetK(array_search($letter, $low) + $k);
$new = array_slice($low, $off, 1)[0];
break;
case ctype_digit($letter):
$new = $letter;
break;
default:
$new = $letter;
break;
}
$newLetters[] = $new;
}
return implode('', $newLetters);
}
示例10: getCompositeProperties
/**
* Get composite properties
*
* @param $class_name string|object The composite class name or object
* @param $property_name string The composite property name
* @return Reflection_Property[] key is the name of the property
*/
public static function getCompositeProperties($class_name = null, $property_name = null)
{
// flexible parameters : first parameter can be a property name alone
if (!isset($property_name) && is_string($class_name) && !empty($class_name)) {
if (ctype_lower($class_name[0])) {
$property_name = $class_name;
$class_name = null;
}
} elseif (is_object($class_name)) {
$class_name = get_class($class_name);
}
$self = get_called_class();
$path = $self . DOT . $class_name . DOT . $property_name;
if (!isset(self::$composite_property_name[$path])) {
self::$composite_property_name[$path] = [];
$properties = empty($property_name) ? (new Reflection_Class($self))->getAnnotedProperties('composite') : [new Reflection_Property($self, $property_name)];
// take the right composite property
foreach ($properties as $property) {
if (!isset($class_name) || is_a($class_name, $property->getType()->asString(), true)) {
self::$composite_property_name[$path][$property->name] = $property;
}
}
if (!self::$composite_property_name[$path]) {
// automatic composite property : filter all properties by class name as type
foreach ((new Reflection_Class($self))->getProperties([T_EXTENDS, T_USE]) as $property) {
if (!isset($class_name) || is_a($class_name, $property->getType()->asString(), true)) {
self::$composite_property_name[$path][$property->name] = $property;
}
}
}
}
return self::$composite_property_name[$path];
}
示例11: filterSet
/**
* Implementation of filterSet() to call set on Translation relationship to allow
* access to I18n properties from the main object.
*
* @param Doctrine_Record $record
* @param string $name Name of the property
* @param string $value Value of the property
* @return void
*/
public function filterSet(Doctrine_Record $record, $fieldName, $value)
{
$translation = $record->get('Translation');
$culture = myDoctrineRecord::getDefaultCulture();
if ($translation->contains($culture)) {
$i18n = $record->get('Translation')->get($culture);
} else {
$i18n = $record->get('Translation')->get($culture);
/*
* If translation is new
* populate it with i18n fallback
*/
if ($i18n->state() == Doctrine_Record::STATE_TDIRTY) {
if ($fallback = $record->getI18nFallBack()) {
$fallBackData = $fallback->toArray();
unset($fallBackData['id'], $fallBackData['lang']);
$i18n->fromArray($fallBackData);
}
}
}
if (!ctype_lower($fieldName) && !$i18n->contains($fieldName)) {
$underscoredFieldName = dmString::underscore($fieldName);
if (strpos($underscoredFieldName, '_') !== false && $i18n->contains($underscoredFieldName)) {
$fieldName = $underscoredFieldName;
}
}
$i18n->set($fieldName, $value);
return $value;
}
示例12: __construct
function __construct()
{
// Check username
if (!SECOND_PARAMETER || !Validate::username(SECOND_PARAMETER)) {
Base::redirect('/oops');
}
$this->user = User::where('username', SECOND_PARAMETER)->findOne();
if (!$this->user) {
Base::redirect('/oops');
}
// Set some variables for template
View::set('page_title', $this->user->username);
View::set('user', $this->user->asArray());
$this->sidebar();
if (!THIRD_PARAMETER) {
$this->user();
} else {
if (ctype_lower(THIRD_PARAMETER) && method_exists($this, THIRD_PARAMETER)) {
$func = THIRD_PARAMETER;
$this->{$func}();
} else {
Base::redirect('/oops');
}
}
}
示例13: buildForm
public function buildForm(FormBuilderInterface $builder, array $options)
{
parent::buildForm($builder, $options);
// custom fields
$builder->add('super', 'checkbox', array('label' => 'Looking for Super Admin account:', 'required' => false));
$builder->add('dbNameUq', 'text', array('label' => 'Database name (only lower case letters):', 'required' => false));
$builder->add('defaultlanguage', 'language', array('label' => 'Default language:', 'required' => false));
// custom validation
$extraValidator = function (FormEvent $event) {
$form = $event->getForm();
$dbNameUq = $form->get('dbNameUq');
$defaultlanguage = $form->get('defaultlanguage');
$super = $form->get('super')->getData();
if (!$super) {
if (!is_null($dbNameUq->getData())) {
if (!ctype_lower($dbNameUq->getData())) {
$dbNameUq->addError(new FormError("This field is not valid (only lower case letters)"));
}
if (strlen($dbNameUq->getData()) < 3 || strlen($dbNameUq->getData()) > 50) {
$dbNameUq->addError(new FormError("This field must contain 3 to 50 lower case letters"));
}
} else {
$dbNameUq->addError(new FormError("This field must not be empty"));
}
if (is_null($defaultlanguage->getData())) {
$defaultlanguage->addError(new FormError("This field must not be empty"));
}
}
};
$builder->addEventListener(FormEvents::POST_BIND, $extraValidator);
}
示例14: _genderise
function _genderise($old_pre, $old, $old_post, $new)
{
// Determine case
$case = NULL;
// work it out here...
if (ctype_upper($old)) {
$case = 'upper';
}
if (ctype_lower($old)) {
$case = 'lower';
}
if (preg_match('/[A-Z][a-z]+/', $old)) {
$case = 'title';
}
// Transform string
switch ($case) {
case 'lower':
return $old_pre . strtolower($new) . $old_post;
break;
case 'upper':
return $old_pre . strtoupper($new) . $old_post;
break;
case 'title':
return $old_pre . title_case($new) . $old_post;
break;
}
return $old_pre . $new . $old_post;
}
示例15: convertSnake
/**
* Convert a string to snake case.
*
* @param string $str
* @param string $delimiter
* @return string
*/
public static function convertSnake($str, $delimiter = '_')
{
if (ctype_lower($str)) {
return $str;
}
return strtolower(preg_replace('/(.)(?=[A-Z])/', '$1' . $delimiter, $str));
}