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


PHP String::capitalize方法代码示例

本文整理汇总了PHP中Nette\String::capitalize方法的典型用法代码示例。如果您正苦于以下问题:PHP String::capitalize方法的具体用法?PHP String::capitalize怎么用?PHP String::capitalize使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Nette\String的用法示例。


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

示例1: attached

 /**
  * This method will be called when the component (or component's parent)
  * becomes attached to a monitored object. Do not call this method yourself.
  * @param  IComponent
  * @return void
  */
 protected function attached($dataGrid)
 {
     if ($dataGrid instanceof DataGrid) {
         $this->setParent($dataGrid->getComponent('columns', TRUE));
         if ($this->caption === NULL) {
             $this->caption = \Nette\String::capitalize($this->getName());
         }
     }
 }
开发者ID:jurasm2,项目名称:datagrid,代码行数:15,代码来源:DataGridColumn.php

示例2: canonicalizeDestination

 private function canonicalizeDestination($destination)
 {
     // searching for any string that wikipedia knows
     $c = curl_init();
     curl_setopt($c, CURLOPT_RETURNTRANSFER, 1);
     curl_setopt($c, CURLOPT_HTTPHEADER, array('Accept: application/json', 'Content-Type: application/json'));
     curl_setopt($c, CURLOPT_USERAGENT, 'Travelbot 1.0 beta');
     curl_setopt($c, CURLOPT_FOLLOWLOCATION, TRUE);
     curl_setopt($c, CURLOPT_MAXREDIRS, 100);
     $uri = new Uri('http://en.wikipedia.org/w/api.php');
     $uri->setQuery(array('format' => 'json', 'action' => 'opensearch', 'search' => $destination, 'limit' => 5));
     curl_setopt($c, CURLOPT_URL, (string) $uri);
     $result = curl_exec($c);
     curl_close($c);
     $json = json_decode($result);
     if ($json === FALSE) {
         throw new InvalidStateException('Malformed JSON response.');
     }
     if (!isset($json[1][0])) {
         throw new ArticleException('Article not found.');
     }
     $destination = $json[1][0];
     // canonization (redirection to the final article)
     $c = curl_init();
     curl_setopt($c, CURLOPT_RETURNTRANSFER, 1);
     curl_setopt($c, CURLOPT_HTTPHEADER, array('Accept: application/json', 'Content-Type: application/json'));
     curl_setopt($c, CURLOPT_USERAGENT, 'Travelbot 1.0 beta');
     curl_setopt($c, CURLOPT_FOLLOWLOCATION, TRUE);
     curl_setopt($c, CURLOPT_MAXREDIRS, 100);
     $uri = new Uri('http://en.wikipedia.org/w/api.php');
     $uri->setQuery(array('format' => 'json', 'action' => 'query', 'titles' => $destination, 'redirects' => TRUE));
     curl_setopt($c, CURLOPT_URL, (string) $uri);
     $result = curl_exec($c);
     curl_close($c);
     $json = json_decode($result);
     if ($json === FALSE) {
         return $destination;
     }
     if (isset($json->query->redirects[0])) {
         return $json->query->redirects[0]->to;
     } else {
         if (isset($json->query->normalized[0])) {
             return String::capitalize($json->query->normalized[0]->to);
         }
     }
     return $destination;
 }
开发者ID:jff15,项目名称:travelbot,代码行数:47,代码来源:ArticleWikipediaMapper.php


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