當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。