• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP ucFirst函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: renderSerialized

 /**
  * Attempts to serialize $var according to $format, setting the
  * proper content type and returning the serialization.
  * TODO: improve content type.
  *
  * @return string
  */
 public function renderSerialized($var, $format)
 {
     if (is_string($var)) {
         $serialized = $var;
     } elseif (is_object($var)) {
         $toMethod = 'to' . ucFirst($format);
         if ($var instanceof \Rails\ActiveRecord\Relation) {
             $serialized = $var->records()->{$toMethod}();
         } else {
             if (is_callable([$var, $toMethod])) {
                 $serialized = $var->{$toMethod}();
             }
         }
     } elseif (is_array($var)) {
         if ($format == 'json') {
             $serialized = json_encode($var);
         }
     }
     if (!isset($serialized)) {
         if (is_object($var)) {
             $message = sprintf("Can't serialize object of class %s to format %s", get_class($var), $format);
         } else {
             $message = sprintf("Can't serialize variable of type %s to format %s", gettype($var), $format);
         }
         throw new Exception\RuntimeException($message);
     }
     $this->controller->response()->setContentType(MimeTypes::getMimeType($format));
     return $serialized;
 }
开发者ID:railsphp,项目名称:framework,代码行数:36,代码来源:Rendering.php


示例2: parse

 public function parse($request)
 {
     if ($this->method && !$request->isMethod($this->method)) {
         return false;
     }
     if ($this->secure && !$request->isSecure()) {
         return false;
     }
     // parse url stuff
     $uri = substr($request->path, strlen(Router::base()));
     if (!preg_match($this->compile(), (string) $uri, $found)) {
         return false;
     }
     foreach ($found as $index => $match) {
         if (is_int($index)) {
             unset($found[$index]);
         }
     }
     $result = $found + $this->params;
     if (!strstr($result['controller'], '\\')) {
         if ($result['controller'] !== 'Controller') {
             $append = 'Controller';
         } else {
             $append = '';
         }
         $result['controller'] = trim($result['namespace'], '\\') . '\\' . ucFirst($result['controller']) . $append;
     }
     unset($result['namespace']);
     return $result;
 }
开发者ID:ephigenia,项目名称:ephframe,代码行数:30,代码来源:Route.php


示例3: testEntityConfigurator

 public function testEntityConfigurator()
 {
     $utils = new Utils();
     $router = $this->_kernel->getContainer()->get('router');
     $translator = $this->_kernel->getContainer()->get('translator');
     $entityName = 'entityconfigurator';
     $route = $router->generate('entitygen');
     $crawler = $this->client->request('GET', $route);
     //navigate to index page
     $this->assertEquals(200, $this->client->getResponse()->getStatusCode(), 'Server error on index ' . $entityName);
     $this->assertGreaterThan(0, $crawler->filter('h1:contains("' . $translator->trans($entityName . '.indextitle') . '")')->count(), 'Navigate to index form of' . $entityName);
     //select and click on Add link
     $link = $crawler->selectLink($translator->trans('buttons.add'))->link();
     $crawler = $this->client->click($link);
     $this->assertEquals(200, $this->client->getResponse()->getStatusCode(), 'Server error on creation ' . $entityName);
     $this->assertGreaterThan(0, $crawler->filter('h1:contains("' . $translator->trans($entityName . '.newtitle') . '")')->count(), 'Navigate to Creation form of' . $entityName);
     $buttonCrawlerNode = $crawler->selectButton($translator->trans('buttons.save'));
     $form = $buttonCrawlerNode->form();
     $var = $utils->getRandomVariable(6, 'string');
     $category = $this->_kernel->getContainer()->get('doctrine')->getEntityManager()->getRepository('LowbiConfiguratorBundle:Category')->findOneByName('Defaut');
     $crawler = $this->client->submit($form, array('lowbi_configuratorbundle_entityconfiguratortype[tableName]' => 'test_' . $var, 'lowbi_configuratorbundle_entityconfiguratortype[bundleName]' => 'LowbiSystemBundle', 'lowbi_configuratorbundle_entityconfiguratortype[entityName]' => 'Entity' . ucFirst($var), 'lowbi_configuratorbundle_entityconfiguratortype[category]' => $category->getId(), 'lowbi_configuratorbundle_entityconfiguratortype[routePrefix]' => $var, 'lowbi_configuratorbundle_entityconfiguratortype[security]' => '1', 'lowbi_configuratorbundle_entityconfiguratortype[administrable]' => '1'));
     /*
     	$this->assertEquals(200,$this->client->getResponse()->getStatusCode(),'Server error on details '.$entityName);
     	$this->assertGreaterThan(0,$crawler->filter('h1:contains("'.$translator->trans($entityName.'.edittitle').'")')->count(),'Navigate to Show form of'.$entityName);
     	
     	
     	//Add fields to the entity
     	$var = $utils->getRandomVariable(6, 'string');
     	$crawler = $this->client->submit($form, array(
     	    'lowbi_configuratorbundle_entityconfiguratortype[fields][0][fieldName]'  => 'field'.$var,
     	    'lowbi_configuratorbundle_entityconfiguratortype[fields][0][fieldType]'  => 'string',
     	    'lowbi_configuratorbundle_entityconfiguratortype[fields][0][fragment]'  => 'text',
     	    'lowbi_configuratorbundle_entityconfiguratortype[fields][0][length]'  => '50',
     	    'lowbi_configuratorbundle_entityconfiguratortype[fields][0][search]'  => '1',
     	    'lowbi_configuratorbundle_entityconfiguratortype[fields][0][required]'  => '1',
     	    'lowbi_configuratorbundle_entityconfiguratortype[fields][1][fieldName]'  => 'fieldOther'.$var,
     	    'lowbi_configuratorbundle_entityconfiguratortype[fields][1][fieldType]'  => 'integer',
     	    'lowbi_configuratorbundle_entityconfiguratortype[fields][1][fragment]'  => 'number',
     	    'lowbi_configuratorbundle_entityconfiguratortype[fields][1][length]'  => '5',
     	    'lowbi_configuratorbundle_entityconfiguratortype[fields][1][search]'  => '1',
     	    'lowbi_configuratorbundle_entityconfiguratortype[fields][1][required]'  => '1',
     	));
     	
     	$this->assertEquals(200,$this->client->getResponse()->getStatusCode(),'Server error on details '.$entityName);
     	$this->assertGreaterThan(0,$crawler->filter('h1:contains("'.$translator->trans($entityName.'.showtitle').'")')->count(),'Navigate to Show form of'.$entityName);
     	
     	//select and click on Edit link
     	$link = $crawler->selectLink($translator->trans('entityconfigurator.loadentity'))->link();
     	$crawler = $this->client->click($link);
     	
     	$this->assertEquals(200,$this->client->getResponse()->getStatusCode(),'Server error on edition '.$entityName);
     	$this->assertGreaterThan(0,$crawler->filter('h1:contains("'.$translator->trans($entityName.'.showtitle').'")')->count(),'Navigate to Show form of'.$entityName);
     
     	$link = $crawler->selectLink($translator->trans('entityconfigurator.loadfield'))->link();
     	$crawler = $this->client->click($link);
     	
     	$this->assertEquals(200,$this->client->getResponse()->getStatusCode(),'Server error on index '.$entityName);
     	$this->assertGreaterThan(0,$crawler->filter('h1:contains("'.$translator->trans($entityName.'.showtitle').'")')->count(),'Navigate to Show form of'.$entityName);
     */
 }
开发者ID:r4cker,项目名称:lowbi,代码行数:60,代码来源:EntityConfiguratorControllerTest.php


示例4: statistics

 function statistics()
 {
     // load Model ForumCategory
     App::import('Model', 'ForumCategory');
     // Initialize $this->ForumCategory object
     $this->ForumCategory = new ForumCategory();
     // get data
     $stat['user'] = $this->ForumCategory->StaffInformation->find('count');
     $stat['category'] = $this->ForumCategory->find('count');
     $stat['topic'] = $this->ForumCategory->ForumTopic->find('count');
     $stat['reply'] = $this->ForumCategory->ForumTopic->ForumReply->find('count');
     // generate HTML for statistics
     $html1 = "\n        <div id='sidebar'>\n        <h2>Statistics</h2>\n        <ol style='list-style-type:none; margin-left:-20px'>\n        ";
     // $html1
     // Foreach
     foreach ($stat as $k => $v) {
         // generate <li>key : value</li> html tag
         $html2[] = $this->Html->tag('li', sprintf("%s : %s", ucFirst($k), $v));
     }
     // Convert Array to String using implode() | php.net/implode
     $html2 = implode(' ', $html2);
     $html3 = "\n        </ol>\n        </div>\n        ";
     // $html3
     echo $html1 . $html2 . $html3;
     // combine all 3 variables and return
 }
开发者ID:uuking,项目名称:Forum-2,代码行数:26,代码来源:site_module.php


示例5: outputConstructor

 public function outputConstructor(ClassEntity $entity)
 {
     // Get the property names
     $propertyNames = array();
     foreach ($entity->getMembers() as $member) {
         if ($member->getType() == 'property') {
             $propertyNames[] = $member->getName();
         }
     }
     // Create the code block line by line
     $lines = array();
     if (count($propertyNames) == 0) {
         $lines[] = "public function __construct()";
     } else {
         $lines[] = "public function __construct(\$" . implode(", \$", $propertyNames) . ")";
     }
     $lines[] = "{";
     foreach ($entity->getMembers() as $member) {
         if ($member->getType() == 'setter') {
             $lines[] = $this->getIndentation() . '$this->set' . ucFirst($member->getName()) . '($' . $member->getName() . ');';
         }
     }
     $lines[] = '}';
     foreach ($lines as $key => $line) {
         $lines[$key] = $this->getIndentation() . $line;
     }
     return implode("\n", $lines);
 }
开发者ID:marijnkoesen,项目名称:php-code-generator,代码行数:28,代码来源:ClassGenerator.php


示例6: getOrganization

 /**
  * Get the organization entered in the Structed data admin if any
  */
 private function getOrganization()
 {
     if (!is_null($this->Org)) {
         return $this->Org;
     }
     $options = get_option('_settingsSettingsStructuredData', true);
     if (isset($options['homepage']) && isset($options['homepage']['Organization']) && isset($options['homepage']['Organization']['legalName']) && isset($options['homepage']['Organization']['url']) && !empty($options['homepage']['Organization']['legalName']) && !empty($options['homepage']['Organization']['url'])) {
         $Org = Schema\OrganizationSchema::factory();
         $add = array('legalName', 'url', 'email', 'telephone', 'faxNumber');
         foreach ($add as $key) {
             if (!empty($options['homepage']['Organization'][$key])) {
                 $func = "set" . ucFirst($key);
                 $Org->{$func}($options['homepage']['Organization'][$key]);
                 // Name is also required in some cases, so duplicate legalName
                 if ($key === 'legalName') {
                     $Org->setName($options['homepage']['Organization'][$key]);
                 }
             }
         }
         if (intval($options['homepage']['Organization']['logo']['id']) > 0) {
             $logo = wp_get_attachment_image_src($options['homepage']['Organization']['logo']['id'], 'full');
             $Org->setLogo($logo[0]);
         }
         // Make Organization available for singular items
         $this->Org = $Org;
     } else {
         $this->Org = false;
     }
     return $this->Org;
 }
开发者ID:nextbuzz,项目名称:buzz-seo,代码行数:33,代码来源:StructuredData.php


示例7: invoke

 public function invoke(Scaffolding $scaffolding)
 {
     $name = ucFirst($this->in->getArgument('name'));
     $file = $scaffolding->createUnitTest($name);
     $this->writeCreatedFilesHeader();
     $this->writeCreatedFile($file);
 }
开发者ID:VasekPurchart,项目名称:khanovaskola-v3,代码行数:7,代码来源:Unit.php


示例8: 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


示例9: createPage

 /**
  * @param array $values
  *
  * @return Page
  */
 protected function createPage(array $values = array())
 {
     $page = new Page();
     foreach ($values as $key => $value) {
         $page->{'set' . ucFirst($key)}($value);
     }
     return $page;
 }
开发者ID:sfarkas1988,项目名称:CmsBundle,代码行数:13,代码来源:AbstractTestCase.php


示例10: modify

 protected function modify(Menu $menu)
 {
     $requete = $this->dao->prepare('UPDATE menus SET name = :name, slug = :slug WHERE id = :id');
     $requete->bindValue(':name', ucFirst($menu->name()), \PDO::PARAM_STR);
     $requete->bindValue(':slug', strtolower(trim(preg_replace('~[^0-9a-z]+~i', '-', html_entity_decode(preg_replace('~&([a-z]{1,2})(?:acute|cedil|circ|grave|lig|orn|ring|slash|copy|th|tilde|uml);~i', '$1', htmlentities($menu->name(), ENT_QUOTES, 'UTF-8')), ENT_QUOTES, 'UTF-8')), '-')), \PDO::PARAM_STR);
     $requete->bindValue(':id', $menu->id(), \PDO::PARAM_INT);
     $requete->execute();
 }
开发者ID:DamdamD,项目名称:Website,代码行数:8,代码来源:MenusManagerPDO.php


示例11: testDetectors

 /**
  * Tests the type detector methods
  *
  * @dataProvider typesProvider
  * @return void
  */
 public function testDetectors($type)
 {
     $event = new SendgridEvent();
     $event->set(array('event' => $type, 'email' => '[email protected]'));
     $this->assertTrue($event->{'is' . ucFirst($type)}());
     $event->type = 'foo';
     $this->assertFalse($event->{'is' . ucFirst($type)}());
 }
开发者ID:lorenzo,项目名称:cakephp-gridhook,代码行数:14,代码来源:SendgridEventTest.php


示例12: onCreateModel

 /**
  * Returns the class that overrides the default One_Model
  *
  * @param One_Scheme $scheme
  * @return One_Model
  */
 public function onCreateModel(One_Scheme $scheme)
 {
     $options = $scheme->get('behaviorOptions.class');
     $className = $options['className'];
     if (!$className) {
         $className = 'One_Model_' . ucFirst($scheme->getName());
     }
     return new $className($scheme);
 }
开发者ID:pdelbar,项目名称:onethree,代码行数:15,代码来源:class.php


示例13: run

 public function run()
 {
     class_exists('gapi') or (require dirname(__FILE__) . '/../../../vendor/gapi/gapi.class.php');
     $ga = new gapi($this->email, $this->password);
     $ga->requestReportData($this->profile_id, array('date'), array($this->metric), null, null, date('Y-m-d', strtotime('yesterday')), date('Y-m-d', strtotime('-' . $this->time)));
     $methodName = 'get' . ucFirst($this->metric);
     $this->result = $ga->{$methodName}();
     return parent::afterConstruct();
 }
开发者ID:holdensmagicalunicorn,项目名称:franklin,代码行数:9,代码来源:GoogleAnalyticsAPITest.php


示例14: handle

 public function handle($what)
 {
     $f = 'handle' . ucFirst(str_replace(['-', '_'], '', $what));
     if (!$what || !method_exists($this, $f)) {
         return null;
     }
     Util::sendNoCacheHeader();
     return $this->{$f}();
 }
开发者ID:aikon-com-cn,项目名称:aowow,代码行数:9,代码来源:ajaxHandler.class.php


示例15: __toString

 /**
  * génère une version string
  * @return string
  */
 public function __toString()
 {
     $method = 'toString' . ucFirst($this->_tag);
     $html = $this->{$method}();
     if (!is_null($this->_tooltip)) {
         $html .= Vue::tooltip($this->_tooltip);
     }
     return $html;
 }
开发者ID:Suire,项目名称:erp-PPE2,代码行数:13,代码来源:formelement.php


示例16: hydrate

 public function hydrate(array $data)
 {
     foreach ($data as $key => $value) {
         $method = "set" . ucFirst($key);
         if (method_exists($this, $method)) {
             $this->{$method}($value);
         }
     }
 }
开发者ID:Arnaldo66,项目名称:formation-php,代码行数:9,代码来源:Personnage.php


示例17: getPageClassName

 /**
  * Gets the simple class name of the given page id.
  *
  * This method doesn't check its parameter. For example, "delete_article"
  * would turn into "DeleteArticlePage", even if no such page would exist.
  * @param string $pageName The page id.
  * @return string The simple class name.
  */
 private function getPageClassName($pageName)
 {
     $pageParts = explode("_", $pageName);
     $pageClassName = 'Rcms\\Page\\';
     foreach ($pageParts as $part) {
         $pageClassName .= ucFirst($part);
     }
     $pageClassName .= "Page";
     return $pageClassName;
 }
开发者ID:rutgerkok,项目名称:rCMS,代码行数:18,代码来源:PageResponder.php


示例18: testSetterAndGetter

 /**
  * @dataProvider getSetterAndGetterProvider
  */
 public function testSetterAndGetter($name, $before, $value)
 {
     $this->assertNotEquals($before, $value);
     $get = 'get' . ucFirst($name);
     $set = 'set' . ucFirst($name);
     $this->assertEquals($before, $this->testClass->{$get}());
     $this->testClass->{$set}($value);
     $this->assertNotEquals($before, $this->testClass->{$get}());
     $this->assertEquals($value, $this->testClass->{$get}());
 }
开发者ID:Vooodoo,项目名称:MediaBundle,代码行数:13,代码来源:MediaTest.php


示例19: __construct

 private function __construct()
 {
     $this->driver = substr(DBNAME, 0, strpos(DBNAME, ":"));
     $helper = __NAMESPACE__ . "\\" . ucFirst($this->driver) . "Helper";
     if (class_exists($helper, true)) {
         $this->helper = new $helper(DBNAME, DBLOGIN, DBPASSWORD);
     } else {
         $this->helper = new PDOHelper(DBNAME, DBLOGIN, DBPASSWORD);
     }
 }
开发者ID:davbfr,项目名称:cf,代码行数:10,代码来源:Bdd.class.php


示例20: rewrite

 /**
  * {@inheritdoc}
  */
 public function rewrite(FunctionCallNode $call, TargetInterface $target)
 {
     $arguments = $call->getArguments();
     if ($arguments[0] instanceof StringNode) {
         $handler_type = $arguments[0]->toValue();
         if ($handler_type == 'validate' || $handler_type == 'submit') {
             return ClassMethodCallNode::create('\\Drupal', 'formBuilder')->appendMethodCall('execute' . ucFirst($handler_type) . 'Handlers')->appendArgument(clone $arguments[1])->appendArgument(clone $arguments[2]);
         }
     }
 }
开发者ID:nishantkumar155,项目名称:drupal8.crackle,代码行数:13,代码来源:FormExecuteHandlers.php



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP ucWords函数代码示例发布时间:2022-05-23
下一篇:
PHP ubermenu_op函数代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap