本文整理汇总了PHP中ucFirst函数的典型用法代码示例。如果您正苦于以下问题:PHP ucFirst函数的具体用法?PHP ucFirst怎么用?PHP ucFirst使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了ucFirst函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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;
}
示例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;
}
示例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);
*/
}
示例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
}
示例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);
}
示例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;
}
示例7: invoke
public function invoke(Scaffolding $scaffolding)
{
$name = ucFirst($this->in->getArgument('name'));
$file = $scaffolding->createUnitTest($name);
$this->writeCreatedFilesHeader();
$this->writeCreatedFile($file);
}
示例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;
}
示例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;
}
示例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();
}
示例11: testDetectors
/**
* Tests the type detector methods
*
* @dataProvider typesProvider
* @return void
*/
public function testDetectors($type)
{
$event = new SendgridEvent();
$event->set(array('event' => $type, 'email' => 'foo@bar.com'));
$this->assertTrue($event->{'is' . ucFirst($type)}());
$event->type = 'foo';
$this->assertFalse($event->{'is' . ucFirst($type)}());
}
示例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);
}
示例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();
}
示例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}();
}
示例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;
}