本文整理汇总了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());
}
}
}
示例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;
}