本文整理汇总了PHP中ucfirst函数的典型用法代码示例。如果您正苦于以下问题:PHP ucfirst函数的具体用法?PHP ucfirst怎么用?PHP ucfirst使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了ucfirst函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: view
/**
* Display a page with this order of priority (based on the provided page name) :
* 1. Does the page exist into local/pages/{lang}/ (this allows you to overwrite default pages)?
* 2. Does the page exist into the views available in views/pages/ folder?
* Pages are not public and we take into account the language of the connected user.
* If the page name contains the keyword export, then we don't output the default template.
* @param string $page Name of the view (and of the corresponding PHP file)
* @author Benjamin BALET <benjamin.balet@gmail.com>
*/
public function view($page = 'home')
{
$data = getUserContext($this);
$trans = array("-" => " ", "_" => " ", "." => " ");
$data['title'] = ucfirst(strtr($page, $trans));
// Capitalize the first letter
//The page containing export in their name are returning another MIMETYPE
if (strpos($page, 'export') === FALSE) {
//Don't include header and menu
$this->load->view('templates/header', $data);
$this->load->view('menu/index', $data);
}
$view = 'pages/' . $this->language_code . '/' . $page . '.php';
$pathCI = APPPATH . 'views/';
$pathLocal = FCPATH . 'local/';
//Check if we have a user-defined view
if (file_exists($pathLocal . $view)) {
$this->load->customView($pathLocal, $view, $data);
} else {
//Load the page from the default location (CI views folder)
if (!file_exists($pathCI . $view)) {
redirect('notfound');
}
$this->load->view($view, $data);
}
if (strpos($page, 'export') === FALSE) {
$this->load->view('templates/footer', $data);
}
}
示例2: factory
/**
* 工厂, 创建操作各种数据库的对象.
*
* @param string|null $db_type 数据库类型, 如果传递 null 或者不传递则默认为 local RThink_Config 的
* db_type
* @param array $options 数据库配置参数
* @return object 操作相应数据库的对象
* @throws em_db_exception
*/
public static function factory($options, $db_type)
{
$adapter_name = ucfirst($db_type) . 'Adapter';
$class_name = 'RThink_Db_' . $adapter_name;
class_exists($class_name, false) || (require 'RThink/Db/' . $adapter_name . '.php');
return new $class_name($options);
}
示例3: ucfirst
/**
*
* Factory method to create Tag Handlers
*
* $type = namespace eg. <flexy:toJavascript loads Flexy.php
* the default is this... (eg. Tag)
*
*
* @param string Namespace handler for element.
* @param object HTML_Template_Flexy_Compiler
*
*
* @return object tag compiler
* @access public
*/
function &factory($type, &$compiler)
{
if (!$type) {
$type = 'Tag';
}
$class = 'HTML_Template_Flexy_Compiler_Flexy_' . $type;
if (class_exists($class)) {
$ret = new $class();
$ret->compiler =& $compiler;
return $ret;
}
$filename = 'HTML/Template/Flexy/Compiler/Flexy/' . ucfirst(strtolower($type)) . '.php';
if (!HTML_Template_Flexy_Compiler_Flexy_Tag::fileExistsInPath($filename)) {
$ret = HTML_Template_Flexy_Compiler_Flexy_Tag::factory('Tag', $compiler);
return $ret;
}
// if we dont have a handler - just use the basic handler.
if (!file_exists(dirname(__FILE__) . '/' . ucfirst(strtolower($type)) . '.php')) {
$type = 'Tag';
}
include_once 'HTML/Template/Flexy/Compiler/Flexy/' . ucfirst(strtolower($type)) . '.php';
$class = 'HTML_Template_Flexy_Compiler_Flexy_' . $type;
if (!class_exists($class)) {
$ret = false;
return $ret;
}
$ret = HTML_Template_Flexy_Compiler_Flexy_Tag::factory($type, $compiler);
return $ret;
}
示例4: __get
public function __get($name)
{
$method = 'get' . ucfirst($name);
if (method_exists($this, $method)) {
return $this->{$method}();
}
}
示例5: process
/**
* Processes this test, when one of its tokens is encountered.
*
* @param PHP_CodeSniffer_File $phpcsFile The file being scanned.
* @param int $stackPtr The position of the current token in the
* stack passed in $tokens.
*
* @return void
*/
public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
{
$tokens = $phpcsFile->getTokens();
// Make sure this is the first PHP open tag so we don't process
// the same file twice.
$prevOpenTag = $phpcsFile->findPrevious(T_OPEN_TAG, $stackPtr - 1);
if ($prevOpenTag !== false) {
return;
}
$fileName = $phpcsFile->getFileName();
$extension = substr($fileName, strrpos($fileName, '.'));
$nextClass = $phpcsFile->findNext(array(T_CLASS, T_INTERFACE), $stackPtr);
if ($extension === '.php') {
if ($nextClass !== false) {
$error = '%s found in ".php" file; use ".inc" extension instead';
$data = array(ucfirst($tokens[$nextClass]['content']));
$phpcsFile->addError($error, $stackPtr, 'ClassFound', $data);
}
} else {
if ($extension === '.inc') {
if ($nextClass === false) {
$error = 'No interface or class found in ".inc" file; use ".php" extension instead';
$phpcsFile->addError($error, $stackPtr, 'NoClass');
}
}
}
}
示例6: load
public function load(TemplateReferenceInterface $template)
{
if (method_exists($this, $method = 'get' . ucfirst($template->get('name')) . 'Template')) {
return new StringStorage($this->{$method}());
}
return false;
}
示例7: getFullClassName
/**
* getFullClassName()
*
* @param string $localClassName
* @param string $classContextName
*/
public function getFullClassName($localClassName, $classContextName = null)
{
// find the ApplicationDirectory OR ModuleDirectory
$currentResource = $this->_resource;
do {
$resourceName = $currentResource->getName();
if ($resourceName == 'ApplicationDirectory' || $resourceName == 'ModuleDirectory') {
$containingResource = $currentResource;
break;
}
} while ($currentResource instanceof Zend_Tool_Project_Profile_Resource && ($currentResource = $currentResource->getParentResource()));
$fullClassName = '';
// go find the proper prefix
if (isset($containingResource)) {
if ($containingResource->getName() == 'ApplicationDirectory') {
$prefix = $containingResource->getAttribute('classNamePrefix');
$fullClassName = $prefix;
} elseif ($containingResource->getName() == 'ModuleDirectory') {
$filter = new Zend_Filter_Word_DashToCamelCase();
$prefix = $filter->filter(ucfirst($containingResource->getAttribute('moduleName'))) . '_';
$fullClassName = $prefix;
}
}
if ($classContextName) {
$fullClassName .= rtrim($classContextName, '_') . '_';
}
$fullClassName .= $localClassName;
return $fullClassName;
}
示例8: generateClass
/**
* Generate Class
*
* @param string $className
* @return string
* @throws \Magento\Framework\Exception
* @throws \InvalidArgumentException
*/
public function generateClass($className)
{
// check if source class a generated entity
$entity = null;
$entityName = null;
foreach ($this->_generatedEntities as $entityType => $generatorClass) {
$entitySuffix = ucfirst($entityType);
// if $className string ends on $entitySuffix substring
if (strrpos($className, $entitySuffix) === strlen($className) - strlen($entitySuffix)) {
$entity = $entityType;
$entityName = rtrim(substr($className, 0, -1 * strlen($entitySuffix)), \Magento\Framework\Autoload\IncludePath::NS_SEPARATOR);
break;
}
}
if (!$entity || !$entityName) {
return self::GENERATION_ERROR;
}
// check if file already exists
$autoloader = $this->_autoloader;
if ($autoloader::getFile($className)) {
return self::GENERATION_SKIP;
}
if (!isset($this->_generatedEntities[$entity])) {
throw new \InvalidArgumentException('Unknown generation entity.');
}
$generatorClass = $this->_generatedEntities[$entity];
$generator = new $generatorClass($entityName, $className, $this->_ioObject);
if (!$generator->generate()) {
$errors = $generator->getErrors();
throw new \Magento\Framework\Exception(implode(' ', $errors));
}
return self::GENERATION_SUCCESS;
}
示例9: render
/**
* Interface with the Module Loader.
*
* @param string $key
* @return string
*/
public function render($key)
{
$getter = 'get' . ucfirst($key);
/** @var \Fab\Vidi\Module\ModuleLoader $moduleLoader */
$moduleLoader = $this->objectManager->get('Fab\\Vidi\\Module\\ModuleLoader');
return $moduleLoader->{$getter}();
}
示例10: getOptions
/**
* Method to get the list of database options.
*
* This method produces a drop down list of available databases supported
* by JDatabaseDriver classes that are also supported by the application.
*
* @return array The field option objects.
*
* @since 11.3
* @see JDatabaseDriver::getConnectors()
*/
protected function getOptions()
{
// This gets the connectors available in the platform and supported by the server.
$available = JDatabaseDriver::getConnectors();
/**
* This gets the list of database types supported by the application.
* This should be entered in the form definition as a comma separated list.
* If no supported databases are listed, it is assumed all available databases
* are supported.
*/
$supported = $this->element['supported'];
if (!empty($supported)) {
$supported = explode(',', $supported);
foreach ($supported as $support) {
if (in_array($support, $available)) {
$options[$support] = JText::_(ucfirst($support));
}
}
} else {
foreach ($available as $support) {
$options[$support] = JText::_(ucfirst($support));
}
}
// This will come into play if an application is installed that requires
// a database that is not available on the server.
if (empty($options)) {
$options[''] = JText::_('JNONE');
}
return $options;
}
示例11: execute
/**
* @param \Symfony\Component\Console\Input\InputInterface $input
* @param \Symfony\Component\Console\Output\OutputInterface $output
* @return int|void
* @throws \InvalidArgumentException
*/
protected function execute(InputInterface $input, OutputInterface $output)
{
$subCommandFactory = $this->createSubCommandFactory($input, $output, 'N98\\Magento\\Command\\Developer\\Module\\Create\\SubCommand');
$configBag = $subCommandFactory->getConfig();
if (!$input->getOption('modman')) {
$this->detectMagento($output);
}
$configBag->setBool('isModmanMode', $input->getOption('modman'));
$configBag->setString('magentoRootFolder', $this->_magentoRootFolder);
$this->initConfigBagDefaultValues($configBag);
if ($input->getOption('add-all')) {
$configBag->setBool('shouldAddBlocks', true);
$configBag->setBool('shouldAddHelpers', true);
$configBag->setBool('shouldAddModels', true);
$configBag->setBool('shouldAddSetup', true);
}
if ($input->getOption('add-blocks')) {
$configBag->setBool('shouldAddBlocks', true);
}
if ($input->getOption('add-helpers')) {
$configBag->setBool('shouldAddHelpers', true);
}
if ($input->getOption('add-models')) {
$configBag->setBool('shouldAddModels', true);
}
if ($input->getOption('add-setup')) {
$configBag->setBool('shouldAddSetup', true);
}
if ($input->getOption('enable')) {
$configBag->setBool('shouldEnableModule', true);
}
$configBag->setString('baseFolder', __DIR__ . '/../../../../../../res/module/create');
$configBag->setString('vendorNamespace', ucfirst($input->getArgument('vendorNamespace')));
$configBag->setString('moduleName', ucfirst($input->getArgument('moduleName')));
$this->initView($input, $configBag);
$subCommandFactory->create('CreateModuleFolders')->execute();
$subCommandFactory->create('CreateModuleRegistrationFiles')->execute();
if (!$input->getOption('minimal')) {
$subCommandFactory->create('CreateModuleConfigFile')->execute();
$subCommandFactory->create('CreateModuleDiFile')->execute();
$subCommandFactory->create('CreateModuleEventsFile')->execute();
$subCommandFactory->create('CreateModuleCrontabFile')->execute();
}
$subCommandFactory->create('EnableModule')->execute();
if ($input->getOption('add-readme')) {
$subCommandFactory->create('CreateReadmeFile')->execute();
}
if ($input->getOption('modman')) {
$subCommandFactory->create('CreateModmanFile')->execute();
}
if ($input->getOption('add-composer')) {
$subCommandFactory->create('CreateComposerFile')->execute();
}
if ($input->getOption('add-setup')) {
$subCommandFactory->create('CreateSetupFiles')->execute();
}
if (!$input->getOption('minimal')) {
$subCommandFactory->create('CreateAdditionalFiles')->execute();
}
}
示例12: listItems
/**
* {@inheritdoc}
*/
protected function listItems(InputInterface $input, \Reflector $reflector = null, $target = null)
{
// only list constants when no Reflector is present.
//
// TODO: make a NamespaceReflector and pass that in for commands like:
//
// ls --constants Foo
//
// ... for listing constants in the Foo namespace
if ($reflector !== null || $target !== null) {
return;
}
// only list constants if we are specifically asked
if (!$input->getOption('constants')) {
return;
}
$category = $input->getOption('user') ? 'user' : $input->getOption('category');
$label = $category ? ucfirst($category) . ' Constants' : 'Constants';
$constants = $this->prepareConstants($this->getConstants($category));
if (empty($constants)) {
return;
}
$ret = array();
$ret[$label] = $constants;
return $ret;
}
示例13: testAutomaticCasing
/**
* @param $test
* @param $expected
*
* @dataProvider providerPlurals
*/
public function testAutomaticCasing($test, $expected)
{
$test = ucfirst($test);
$expected = ucfirst($expected);
$pluralize = new Pluralize();
$this->assertEquals($expected, $pluralize->fix($test));
}
示例14: write
/**
* Writes given message to a log file in the logs directory.
*
* @param string $type Type of log, becomes part of the log's filename
* @param string $msg Message to log
* @return boolean Success
*/
function write($type, $msg)
{
$filename = LOGS . $type . '.log';
$output = date('Y-m-d H:i:s') . ' ' . ucfirst($type) . ': ' . $msg . "\n";
$log = new File($filename);
return $log->append($output);
}
示例15: formatTokens
public function formatTokens($content)
{
$upperCaseModelName = ucfirst($this->modelName);
$field_name = snake_case($this->modelName) . '_name';
$modelId = $this->formatInstanceVariable() . '->id';
$modelAttribute = $this->formatInstanceVariable() . '->' . $field_name;
$createdAt = $this->formatInstanceVariable() . '->created_at';
$modelRoute = '/' . $this->folderName;
$dtTableName = snake_case($this->modelName) . '_table';
$masterPage = $this->masterPage;
$modelName = $this->modelName;
$modelsUpperCase = ucwords(str_plural($this->modelName));
$folderName = $this->folderName;
$gridName = $this->formatVueGridName() . '-grid';
$endGridName = '/' . $this->formatVueGridName() . '-grid';
$vueApiRoute = 'api/' . $this->folderName . '-vue';
$parent = $this->parent;
$parentInstance = $this->formatParentInstanceVariable($this->parent);
$parentInstances = $this->formatParents($this->parent);
$parent_id = strtolower(snake_case($this->parent)) . '_id';
$parentFieldName = strtolower(snake_case($this->parent)) . '_name';
$child = $this->child;
$slug = $this->slug;
//create token array using compact
$tokens = compact('upperCaseModelName', 'field_name', 'modelId', 'modelAttribute', 'createdAt', 'modelRoute', 'dtTableName', 'masterPage', 'modelName', 'modelsUpperCase', 'folderName', 'gridName', 'endGridName', 'vueApiRoute', 'parent', 'parentInstance', 'parentInstances', 'parent_id', 'parentFieldName', 'child', 'slug');
$content = $this->insertTokensInContent($content, $tokens);
return $content;
}