当前位置: 首页>>代码示例>>PHP>>正文


PHP ctype_upper函数代码示例

本文整理汇总了PHP中ctype_upper函数的典型用法代码示例。如果您正苦于以下问题:PHP ctype_upper函数的具体用法?PHP ctype_upper怎么用?PHP ctype_upper使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了ctype_upper函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: __call

 function __call($func, $args)
 {
     $di = property_exists($this, 'di') && $this->di instanceof Di ? $this->di : Di::getInstance();
     if (substr($func, 0, 4) == 'call' && ctype_upper(substr($func, 4, 1)) && (method_exists($this, $m = lcfirst(substr($func, 4))) || method_exists($this, $m = '_' . $m))) {
         $params = $di->methodGetParams($this, $m, $args);
         $closure = function () use($m, $params) {
             return call_user_func_array([$this, $m], $params);
         };
         $closure->bindTo($this);
         return $closure();
     }
     $method = '_' . $func;
     if (method_exists($this, $method)) {
         if (!(new \ReflectionMethod($this, $method))->isPublic()) {
             throw new \RuntimeException("The called method is not public.");
         }
         return $di->method($this, $method, $args);
     }
     if (($c = get_parent_class($this)) && method_exists($c, __FUNCTION__)) {
         $m = new \ReflectionMethod($c, __FUNCTION__);
         $dc1 = $m->getDeclaringClass()->name;
         $dc2 = (new \ReflectionMethod($this, __FUNCTION__))->getDeclaringClass()->name;
         $dc3 = get_class($this);
         if ($dc1 != $dc2 || $dc2 != $dc3 && $dc1 != $dc3) {
             return parent::__call($func, $args);
         }
     }
     throw new \BadMethodCallException('Call to undefined method ' . get_class($this) . '->' . $func);
 }
开发者ID:redcatphp,项目名称:ding,代码行数:29,代码来源:CallTrait.php

示例2: __call

 public function __call($method, $arguments)
 {
     if (empty($arguments)) {
         $this->query .= "/{$method}";
         return $this;
     }
     if (!is_array($arguments)) {
         throw new \Exception("Method {$method}() must have an array argument.");
     }
     if (ctype_upper($method[0]) && preg_match_all('/([A-Z]{1}[a-z]+)/', $method)) {
         throw new \Exception('Method names must be declared in camelCase.');
     } elseif (!ctype_upper($method[0]) && preg_match_all('/([A-Z]{1}[a-z]+)/', $method)) {
         $pieces = preg_split('/(?=[A-Z])/', $method);
         foreach ($pieces as $word) {
             if (!ctype_upper($word[0])) {
                 $this->query .= "/{$word}";
             } else {
                 $this->query .= "_{$word}";
             }
         }
     } elseif (!ctype_upper($method[0]) && !preg_match_all('/([A-Z]{1}[a-z]+)/', $method)) {
         $this->query .= "/{$method}";
     } else {
         throw new \Exception('Something went wrong. Bad method name i guess.');
     }
     return $this->request(strtolower($this->query), $arguments[0]);
 }
开发者ID:somepony,项目名称:yandexpddapi,代码行数:27,代码来源:API.php

示例3: queryErrorHandlingISO

function queryErrorHandlingISO()
{
    if (empty($_GET['iso']) || is_numeric($_GET['iso']) || strlen($_GET['iso']) != 2 || !ctype_upper($_GET['iso'])) {
        header("Location: error.php");
        die;
    }
}
开发者ID:kitsutoNT,项目名称:WebII-assignment-,代码行数:7,代码来源:functions.php

示例4: _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;
 }
开发者ID:nailsapp,项目名称:common,代码行数:28,代码来源:NAILS_inflector_helper.php

示例5: parse_class_path

    function parse_class_path($class_name)
    {
        // Парсим директории
        $directories = array_reverse(explode('_', $class_name));

        foreach ($directories as &$directory)
        {
            $new_directory = '';

            for ($i = 0; $i < strlen($directory); $i++)
            {
                // Если это большая буква, то добавляем перед ней '_'
                if ($i != 0 && ctype_upper($directory[$i]))
                    $new_directory .= '_';

                $new_directory .= $directory[$i];
            }

            $directory = strtolower($new_directory);
        }

        $class_path = implode('/', $directories);

        return $class_path;
    }
开发者ID:noxt,项目名称:MChA_Course,代码行数:25,代码来源:autoloader.php

示例6: executeDir

 function executeDir($directory)
 {
     $iterator = new DirectoryIterator($directory);
     while ($iterator->valid()) {
         $entry = $iterator->getFilename();
         $path = $directory . '/' . $entry;
         $iterator->next();
         if ($entry[0] == '.') {
             continue;
         }
         if (is_file($path)) {
             if (substr($entry, -4) != '.php') {
                 continue;
             }
             if (ctype_upper($entry[0])) {
                 $test = new DocTest($path);
                 if ($test->failed()) {
                     echo $test->toString();
                     $this->fail('Doc test failed.');
                 } else {
                     if ($test->numOfPassed()) {
                         echo ',';
                     } else {
                         echo ' ';
                     }
                 }
             }
         } elseif (is_dir($path)) {
             $this->executeDir($path);
         }
     }
 }
开发者ID:BackupTheBerlios,项目名称:ubook-svn,代码行数:32,代码来源:DocumentationTest.php

示例7: 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);
}
开发者ID:ucha19871,项目名称:algorithms,代码行数:27,代码来源:caesarCipher.php

示例8: convertCamelCaseToUnderscore

 /**
  * Converts a CamelCase string to underscores
  * Used to convert pathnames
  * e.g. CamelCase/Path -> camel_case_path
  *
  * @param string $string
  * @throws \Exception when empty string passed is not a string
  * @throws \Exception when empty string is passed
  *
  * @return string $string
  */
 public static function convertCamelCaseToUnderscore($string)
 {
     $new_parts = array();
     if (!is_string($string)) {
         throw new \Exception('Unexpected value for string in Utilities::convertCamelCaseToUnderscore expecting `string`');
     }
     if (strlen($string) < 1) {
         throw new \Exception('Cannot convert empty string from camelCase to underscore');
     }
     if (substr($string, 0, 1) === '/') {
         $string = preg_replace('/^(\\/+)/', '', $string);
     }
     if (substr($string, strlen($string) - 1) === '/') {
         $string = preg_replace('/(\\/+)$/', '', $string);
     }
     $parts = explode('/', $string);
     foreach ($parts as $index => $part) {
         $replacement = strtolower(preg_replace('/([A-Z])/', '_$1', $part));
         if (ctype_upper(substr($part, 0, 1)) === true) {
             $part = substr($replacement, 1);
         } else {
             $part = $replacement;
         }
         $new_parts[] = $part;
     }
     $string = implode('_', $new_parts);
     return $string;
 }
开发者ID:lewnelson,项目名称:namecheap-interface,代码行数:39,代码来源:Utilities.php

示例9: loadClass

 public function loadClass($oopElement)
 {
     $ds = DIRECTORY_SEPARATOR;
     $oopElementOriginal = $oopElement;
     $oopElement = str_replace(array('\\', '/'), array($ds, $ds), $oopElement);
     $tmp = explode($ds, $oopElement);
     $oopElementName = end($tmp);
     $suffix = ".class";
     if (strpos($oopElementName, 'I') === 0 && ctype_upper(substr($oopElementName, 0, 2))) {
         $suffix = ".interface";
     }
     $suffix .= ".php";
     if (isset($tmp[0])) {
         $tmp[0] = lcfirst($tmp[0]);
     }
     if (isset($tmp[1])) {
         $tmp[1] = lcfirst($tmp[1]);
     }
     $oopElement = implode($ds, $tmp);
     $file = $this->rootDir . str_replace('\\', $ds, $oopElement) . $suffix;
     if (is_file($file) && !class_exists($oopElementOriginal)) {
         /** @noinspection PhpIncludeInspection */
         require $file;
     }
 }
开发者ID:Miljankg,项目名称:simplef,代码行数:25,代码来源:ClassLoader.class.php

示例10: run

 /**
  * {@inheritdoc}
  */
 protected function run(CommitInterface $commit)
 {
     $firstLetter = substr($commit->getMessage(), 0, 1);
     if (!ctype_upper($firstLetter)) {
         $this->addViolation($commit);
     }
 }
开发者ID:anroots,项目名称:pgca,代码行数:10,代码来源:StartsWithCapitalLetter.php

示例11: outputCountriesWithVisits

function outputCountriesWithVisits($dbAdapter)
{
    $id = $_GET[continent];
    if (!empty($id) && !is_numeric($id) && strlen($id) == 2 && ctype_upper($id)) {
        $gateCountry = new CountryTableGateway($dbAdapter);
        $result = $gateCountry->findCountriesWithCountsById($id);
        echo '<table class="mdl-data-table mdl-js-data-table mdl-shadow--2dp">
          <thead>
            <tr>
              <th class="mdl-data-table__cell--non-numeric">Country</th>
              <th>Visits</th>
            </tr>
          </thead>
          <tbody>';
        foreach ($result as $row) {
            echo '<tr>
          <td class="mdl-data-table__cell--non-numeric">' . $row->CountryName . '</td>
          <td>' . $row->VisitsFromCountry . '</td>
          </tr>';
        }
        echo '</tbody>
            </table>';
    } else {
        echo "<h2>Chosen continent does not exist</h2>";
    }
}
开发者ID:kitsutoNT,项目名称:Assignment-1-RyaNoBohan,代码行数:26,代码来源:PHPver.AdminDashboard.php

示例12: mapi_break_into_sentences

function mapi_break_into_sentences($input)
{
    $text = trim(strip_tags($input));
    $text_array = explode('.', $text);
    $sentences = array();
    $sentence = '';
    if (sizeof($text_array) < 1) {
        return $text;
    }
    for ($i = 0; $i < sizeof($text_array); $i++) {
        $fos_uppercase = false;
        if (isset($text_array[$i + 1])) {
            if (ctype_upper(substr($text_array[$i + 1], 0, 1))) {
                $fos_uppercase = true;
            }
            if (ctype_upper(substr($text_array[$i + 1], 1, 1))) {
                $fos_uppercase = true;
            }
        } else {
            $fos_uppercase = true;
        }
        $sentence .= $text_array[$i] . '.';
        if ($fos_uppercase) {
            $sentences[] = $sentence;
            $sentence = '';
        }
    }
    return $sentences;
}
开发者ID:adncentral,项目名称:mapi-geoCMS,代码行数:29,代码来源:helper.php

示例13: bold

 function bold()
 {
     $this->CI =& get_instance();
     $content = "";
     $output = $this->CI->output->get_output();
     $dom = new DOMDocument();
     $dom->loadHTML($output);
     $finder = new DomXPath($dom);
     $classname = "lead";
     $nodes = $finder->query("//*[contains(concat(' ', normalize-space(@class), ' '), ' {$classname} ')]");
     foreach ($nodes as $node) {
         $words = explode(' ', $node->nodeValue);
         $temp = $dom->createElement("p");
         $temp->setAttribute("class", "lead");
         foreach ($words as $word) {
             if (ctype_upper($word[0])) {
                 //First char is uppercase
                 $newNode = $dom->createElement('strong', $word . " ");
                 $temp->appendChild($newNode);
             } else {
                 $newNode = $dom->createTextNode($word . " ");
                 $temp->appendChild($newNode);
             }
         }
         $node->parentNode->replaceChild($temp, $node);
     }
     echo $dom->saveHTML();
 }
开发者ID:askho,项目名称:starter-lab03,代码行数:28,代码来源:DisplayOverride.php

示例14: singularify

 /**
  * Returns the singular form of a word
  *
  * If the method can't determine the form with certainty, an array of the
  * possible singulars is returned.
  *
  * @param string $plural A word in plural form
  * @return string|array The singular form or an array of possible singular
  *                      forms
  */
 public static function singularify($plural)
 {
     $pluralRev = strrev($plural);
     $lowerPluralRev = strtolower($pluralRev);
     $pluralLength = strlen($lowerPluralRev);
     // The outer loop $i iterates over the entries of the plural table
     // The inner loop $j iterates over the characters of the plural suffix
     // in the plural table to compare them with the characters of the actual
     // given plural suffix
     for ($i = 0, $numPlurals = count(self::$pluralMap); $i < $numPlurals; ++$i) {
         $suffix = self::$pluralMap[$i][self::PLURAL_SUFFIX];
         $suffixLength = self::$pluralMap[$i][self::PLURAL_SUFFIX_LENGTH];
         $j = 0;
         // Compare characters in the plural table and of the suffix of the
         // given plural one by one
         while ($suffix[$j] === $lowerPluralRev[$j]) {
             // Let $j point to the next character
             ++$j;
             // Successfully compared the last character
             // Add an entry with the singular suffix to the singular array
             if ($j === $suffixLength) {
                 // Is there any character preceding the suffix in the plural string?
                 if ($j < $pluralLength) {
                     $nextIsVocal = false !== strpos('aeiou', $lowerPluralRev[$j]);
                     if (!self::$pluralMap[$i][self::PLURAL_SUFFIX_AFTER_VOCAL] && $nextIsVocal) {
                         break;
                     }
                     if (!self::$pluralMap[$i][self::PLURAL_SUFFIX_AFTER_CONS] && !$nextIsVocal) {
                         break;
                     }
                 }
                 $newBase = substr($plural, 0, $pluralLength - $suffixLength);
                 $newSuffix = self::$pluralMap[$i][self::SINGULAR_SUFFIX];
                 // Check whether the first character in the plural suffix
                 // is uppercased. If yes, uppercase the first character in
                 // the singular suffix too
                 $firstUpper = ctype_upper($pluralRev[$j - 1]);
                 if (is_array($newSuffix)) {
                     $singulars = array();
                     foreach ($newSuffix as $newSuffixEntry) {
                         $singulars[] = $newBase . ($firstUpper ? ucfirst($newSuffixEntry) : $newSuffixEntry);
                     }
                     return $singulars;
                 }
                 return $newBase . ($firstUpper ? ucFirst($newSuffix) : $newSuffix);
             }
             // Suffix is longer than word
             if ($j === $pluralLength) {
                 break;
             }
         }
     }
     // Convert teeth to tooth, feet to foot
     if (false !== ($pos = strpos($plural, 'ee'))) {
         return substr_replace($plural, 'oo', $pos, 2);
     }
     // Assume that plural and singular is identical
     return $plural;
 }
开发者ID:navassouza,项目名称:symfony,代码行数:69,代码来源:FormUtil.php

示例15: isUpperCamelCase

 public static function isUpperCamelCase($str)
 {
     if (!ctype_upper(substr($str, 0, 1))) {
         return false;
     } elseif (!ctype_alpha($str)) {
         return false;
     }
     return true;
 }
开发者ID:RobinTheHood,项目名称:php-framework,代码行数:9,代码来源:naming_convention.php


注:本文中的ctype_upper函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。