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


PHP Strings::substring方法代码示例

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


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

示例1: maybeReplacePlaceholderWithPrefix

 private function maybeReplacePlaceholderWithPrefix($key)
 {
     if (Strings::startsWith($key, self::PREFIX_PLACEHOLDER)) {
         return $this->dbPrefix . Strings::substring($key, Strings::length(self::PREFIX_PLACEHOLDER));
     }
     return $key;
 }
开发者ID:wp-cpm,项目名称:versionpress,代码行数:7,代码来源:UserMetaStorage.php

示例2: __invoke

 /**
  * @param \Nette\Application\Application $application
  * @param \Nette\Application\Request $request
  */
 public function __invoke(Application $application, Request $request)
 {
     if (PHP_SAPI === 'cli') {
         newrelic_background_job(TRUE);
     }
     $params = $request->getParameters();
     $action = $request->getPresenterName();
     if (isset($params[$this->actionKey])) {
         $action = sprintf('%s:%s', $action, $params[$this->actionKey]);
     }
     if (!empty($this->map)) {
         foreach ($this->map as $pattern => $appName) {
             if ($pattern === '*') {
                 continue;
             }
             if (Strings::endsWith($pattern, '*')) {
                 $pattern = Strings::substring($pattern, 0, -1);
             }
             if (Strings::startsWith($pattern, ':')) {
                 $pattern = Strings::substring($pattern, 1);
             }
             if (Strings::startsWith($action, $pattern)) {
                 \VrtakCZ\NewRelic\Tracy\Bootstrap::setup($appName, $this->license);
                 break;
             }
         }
     }
     newrelic_name_transaction($action);
     newrelic_disable_autorum();
 }
开发者ID:vrtak-cz,项目名称:newrelic-nette,代码行数:34,代码来源:OnRequestCallback.php

示例3: sanitize

 /**
  * Filter: removes unnecessary whitespace and shortens value to control's max length.
  *
  * @return string
  */
 public function sanitize($value)
 {
     if ($this->control->maxlength && Nette\Utils\Strings::length($value) > $this->control->maxlength) {
         $value = Nette\Utils\Strings::substring($value, 0, $this->control->maxlength);
     }
     return Nette\Utils\Strings::trim(strtr($value, "\r\n", '  '));
 }
开发者ID:TheTypoMaster,项目名称:SPHERE-Framework,代码行数:12,代码来源:TextInput.php

示例4: computeHash

 /**
  * @param string|array $file
  * @param int $time
  * @param bool $debugMode
  *
  * @return string
  */
 public static function computeHash($file, $time, $debugMode)
 {
     $debug = $debugMode ? 1 : 0;
     $file = is_array($file) ? implode(',', $file) : $file;
     $md5Raw = md5("{$debug};{$file};{$time}", TRUE);
     $base64 = Strings::replace(base64_encode($md5Raw), '~\\W~');
     return Strings::substring(Strings::webalize($base64), 0, 8);
 }
开发者ID:sw2eu,项目名称:load-common,代码行数:15,代码来源:Helpers.php

示例5: getTable

 /**
  * Model\Entity\SomeEntity -> some_entity
  * @param string $entityClass
  * @return string
  */
 public function getTable($entityClass)
 {
     if (Strings::endsWith($entityClass, 'y')) {
         return $this->camelToUnderdash(Strings::substring($this->trimNamespace($entityClass), 0, Strings::length($entityClass))) . 'ies';
     } else {
         return $this->camelToUnderdash($this->trimNamespace($entityClass)) . 's';
     }
 }
开发者ID:kizi,项目名称:easyminer-easyminercenter,代码行数:13,代码来源:StandardMapper.php

示例6: toCamelCase

 /**
  * Converts the given string to "camelCase".
  * @param string $string
  * @return string
  */
 public static function toCamelCase($string)
 {
     static $canUse = null;
     if (is_null($canUse)) {
         $canUse = method_exists(Strings::class, 'firstLower');
         // Nette/Utils >= 2.3 only
     }
     $pascal = self::toPascalCase($string);
     return $canUse ? Strings::firstLower($pascal) : Strings::lower(Strings::substring($pascal, 0, 1)) . Strings::substring($pascal, 1);
 }
开发者ID:meridius,项目名称:helpers,代码行数:15,代码来源:StringHelper.php

示例7: normalizeGithubRepositoryUrl

 /**
  * @param string
  * @return string
  */
 public static function normalizeGithubRepositoryUrl($url)
 {
     self::assertGithubRepositoryUrl($url);
     $url = str_replace('github.com:', 'github.com/', $url);
     if (Strings::endsWith($url, '.git')) {
         $url = Strings::substring($url, 0, -4);
     }
     $match = Strings::match($url, '~' . self::GITHUB_REGEXP . '~');
     return 'https://' . Strings::lower($match[0]);
 }
开发者ID:newPOPE,项目名称:web-addons.nette.org,代码行数:14,代码来源:UrlsHelper.php

示例8: createRoute

 public function createRoute($title, $contentId, $sectionId)
 {
     $route = array();
     $route['contentId'] = $contentId;
     $webalize = \Nette\Utils\Strings::webalize($title);
     $webalize = \Nette\Utils\Strings::substring($webalize, 0, 50);
     $route['url'] = "program/" . $sectionId . "/" . $webalize;
     $route['creationTime'] = date("Y-m-d G:i:s");
     return $route;
 }
开发者ID:bombush,项目名称:NatsuCon,代码行数:10,代码来源:Programme.php

示例9: sanitizeFileName

 /**
  * @param FileUpload $fileUpload
  * @return string
  */
 public static function sanitizeFileName(FileUpload $fileUpload)
 {
     $filename = $fileUpload->getSanitizedName();
     $filename = Strings::lower($filename);
     $fileInfo = new \SplFileInfo($filename);
     $suffix = $fileInfo->getExtension();
     $basename = $fileInfo->getBasename(".{$suffix}");
     $hash = md5($fileUpload->getContents());
     $hash = Strings::substring($hash, 0, 9);
     return Strings::substring($basename, 0, 50) . "_{$hash}.{$suffix}";
 }
开发者ID:ondrs,项目名称:upload-manager,代码行数:15,代码来源:Utils.php

示例10: getNormalizedRouterName

 /**
  * @return string|NULL
  */
 private function getNormalizedRouterName()
 {
     $config = $this->getConfig($this->defaults);
     if (empty($config['router'])) {
         return NULL;
     }
     if (Strings::startsWith($config['router'], '@')) {
         return Strings::substring($config['router'], 1);
     }
     return $config['router'];
 }
开发者ID:nella,项目名称:simple-hash-authenticator,代码行数:14,代码来源:Extension.php

示例11: getValue

 /**
  * Returns control's value.
  * @return string
  */
 public function getValue()
 {
     $value = $this->value;
     if (!empty($this->control->maxlength)) {
         $value = Strings::substring($value, 0, $this->control->maxlength);
     }
     foreach ($this->filters as $filter) {
         $value = (string) call_user_func($filter, $value);
     }
     return $value === Strings::trim($this->translate($this->emptyValue)) ? '' : $value;
 }
开发者ID:vol0054,项目名称:vizitky,代码行数:15,代码来源:TextBase.php

示例12: zipDirToFile

 /**
  * @param string $source
  * @param string $zipFile
  */
 public function zipDirToFile($source, $zipFile)
 {
     $archive = new ZipArchive();
     $archive->open($zipFile, ZipArchive::CREATE);
     $directory = basename($zipFile, '.zip');
     /** @var SplFileInfo $file */
     foreach (Finder::findFiles('*')->from($source) as $file) {
         $relativePath = Strings::substring($file->getRealPath(), strlen($source) + 1);
         $archive->addFile($file, $directory . '/' . $relativePath);
     }
     $archive->close();
 }
开发者ID:rafasashi,项目名称:ApiGen,代码行数:16,代码来源:ZipArchiveGenerator.php

示例13: match

 /**
  * Match request
  * @param  IRequest $request 
  * @return Request            
  */
 public function match(Http\IRequest $request)
 {
     $path = $request->url->getPathInfo();
     if (!Strings::contains($path, $this->prefix)) {
         return NULL;
     }
     $path = Strings::substring($path, strlen($this->prefix) + 1);
     $pathParts = explode('/', $path);
     $pathArguments = array_slice($pathParts, 1);
     $action = $this->getActionName($request->getMethod(), $pathArguments);
     $params = $this->getPathParameters($pathArguments);
     $params[Route::MODULE_KEY] = $this->module;
     $params[Route::PRESENTER_KEY] = $pathParts[0];
     $params['action'] = $action;
     $presenter = ($this->module ? $this->module . ':' : '') . $params[Route::PRESENTER_KEY];
     $appRequest = new Application\Request($presenter, $request->getMethod(), $params, $request->getPost(), $request->getFiles());
     return $appRequest;
 }
开发者ID:marten-cz,项目名称:Restful,代码行数:23,代码来源:StrictRoute.php

示例14: renderSitemap

 /**
  * @param string
  */
 public function renderSitemap($type = 'html')
 {
     $this->template->addons = $this->addons->findAll();
     $this->template->vendors = $this->addons->findVendors();
     $this->template->categories = $this->tags->findMainTags();
     $pages = array();
     foreach (Finder::findFiles('*.texy')->from($this->pagesDataPath) as $file) {
         /** @var \SplFileInfo $file */
         $slug = Strings::substring($file->getRealPath(), Strings::length($this->pagesDataPath) + 1, -5);
         $data = $this->pageProcessor->process(file_get_contents($file->getRealPath()));
         $createdAt = new \DateTime();
         $createdAt->setTimestamp($file->getMTime());
         $pages[] = (object) array('slug' => $slug, 'name' => $data['title'], 'createdAt' => $createdAt);
     }
     $this->template->pages = $pages;
     if ($type == 'xml') {
         $this->setView('sitemap.xml');
     }
 }
开发者ID:newPOPE,项目名称:web-addons.nette.org,代码行数:22,代码来源:SpecialPresenter.php

示例15: translate

 public function translate($message, $count = NULL, $parameters = array(), $domain = NULL, $locale = NULL)
 {
     $translationString = $message instanceof Phrase ? $message->message : $message;
     $prefix = $this->prefix . '.';
     if (Strings::startsWith($message, '//')) {
         $prefix = NULL;
         $translationString = Strings::substring($translationString, 2);
     }
     if ($message instanceof Phrase) {
         return $this->translator->translate(new Phrase($prefix . $translationString, $message->count, $message->parameters, $message->domain, $message->locale));
     }
     if (is_array($count)) {
         $locale = $domain ?: NULL;
         $domain = $parameters ?: NULL;
         $parameters = $count ?: array();
         $count = NULL;
     }
     return $this->translator->translate($prefix . $translationString, $count, (array) $parameters, $domain, $locale);
 }
开发者ID:tomasstrejcek,项目名称:Translation,代码行数:19,代码来源:PrefixedTranslator.php


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