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


PHP ends_with函数代码示例

本文整理汇总了PHP中ends_with函数的典型用法代码示例。如果您正苦于以下问题:PHP ends_with函数的具体用法?PHP ends_with怎么用?PHP ends_with使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


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

示例1: asset

 /**
  * Generate an absolute URL to the given asset.
  *
  * @param  string $asset
  * @param  mixed $extra
  * @param  bool|null $secure
  * @return string
  */
 public function asset($asset, $extra = [], $secure = null)
 {
     // First we will check if the URL is already a valid URL. If it is we will not
     // try to generate a new one but will simply return the URL as is, which is
     // convenient since developers do not always have to check if it's valid.
     if ($this->isValidUrl($asset)) {
         return $asset;
     }
     $scheme = $this->getScheme($secure);
     $extra = $this->formatParameters($extra);
     $tail = implode('/', array_map('rawurlencode', (array) $extra));
     // Once we have the scheme we will compile the "tail" by collapsing the values
     // into a single string delimited by slashes. This just makes it convenient
     // for passing the array of parameters to this URL as a list of segments.
     $root = $this->getRootUrl($scheme);
     if (defined('LOCALE') && ends_with($root, $search = '/' . LOCALE)) {
         $root = substr_replace($root, '', strrpos($root, $search), strlen($search));
     }
     if (($queryPosition = strpos($asset, '?')) !== false) {
         $query = mb_substr($asset, $queryPosition);
         $asset = mb_substr($asset, 0, $queryPosition);
     } else {
         $query = '';
     }
     return $this->trimUrl($root, $asset, $tail) . $query;
 }
开发者ID:jacksun101,项目名称:streams-platform,代码行数:34,代码来源:UrlGenerator.php

示例2: normalizeJsFile

 /**
  * 
  */
 public static function normalizeJsFile($content)
 {
     $content = self::removeMultiLineComments($content);
     $fileLines = explode("\n", $content);
     $taken = array();
     $scipSwap = array('//', '--');
     $swap = array('{', '}', '}}', '{{', '},', '};', '});', 'else', '}else{', '}else', 'else{', '})', 'return;', 'return{');
     $swap_start_end = array('?', ':', '.', '+', '||', '&&', ',', ';');
     $swap_end = array('{', '(');
     $swap_start = array('}');
     $swap_end = array_merge($swap_end, $swap_start_end);
     $swap_start = array_merge($swap_start, $swap_start_end);
     foreach ($fileLines as $line) {
         $line = trim($line);
         //Обрежем строчный комментарий
         //Нужно быть осторожным - двойной слеш может использоваться (в RegExt например)
         if ($line && contains_substring($line, '//')) {
             $line = trim(substr($line, 0, strpos($line, '//')));
         }
         if (!$line) {
             continue;
         }
         $tmp = normalize_string($line, true);
         $prevTmp = count($taken) > 0 ? normalize_string($taken[count($taken) - 1], true) : null;
         if ($prevTmp !== null && !contains_substring($prevTmp, $scipSwap) && (in_array($tmp, $swap) || ends_with($prevTmp, $swap_end) || starts_with($tmp, $swap_start))) {
             $taken[count($taken) - 1] .= ' ' . $line;
         } else {
             $taken[] = $line;
         }
     }
     return trim(implode("\n", $taken));
 }
开发者ID:ilivanoff,项目名称:www,代码行数:35,代码来源:StringUtils.php

示例3: load

 /**
  * Загружает глобальные настройки из файла и кеширует их в массиве GLOBALS.
  * Данный метод вызывается ТОЛЬКО при создании экземпляра класса.
  */
 private function load()
 {
     check_condition(!is_array($this->GLOBALS), 'Недопустима повторная загрузка глобальных настроек');
     $this->GLOBALS = array();
     $this->FileMtimeUpdate();
     $comment = array();
     foreach ($this->DI->getFileLines() as $line) {
         $line = trim($line);
         if (!$line || starts_with($line, '/*') || ends_with($line, '*/')) {
             continue;
         }
         if (starts_with($line, '*')) {
             $line = trim(first_char_remove($line));
             if ($line) {
                 $comment[] = $line;
             }
             continue;
         }
         if (starts_with($line, 'define')) {
             $name = trim(array_get_value(1, explode("'", $line, 3)));
             check_condition($name && defined($name), "Ошибка разбора файла глобальных настроек: свойство [{$name}] не определено.");
             $this->GLOBALS[$name] = new PsGlobalProp($name, implode(' ', $comment));
             $comment = array();
             continue;
         }
     }
 }
开发者ID:ilivanoff,项目名称:www,代码行数:31,代码来源:PsGlobals.php

示例4: getProps

 public function getProps()
 {
     if (is_array($this->props)) {
         return $this->props;
     }
     $this->props = array();
     if (!$this->di->isFile()) {
         return $this->props;
     }
     $prop = null;
     $content = array();
     foreach ($this->di->getFileLines() as $line) {
         $line = trim($line);
         if (!$line) {
             continue;
         }
         if (starts_with($line, '[') && ends_with($line, ']')) {
             //Нашли свойство. Приверим, а нет ли информации о предыдущем свойстве
             if ($prop) {
                 $this->props[$prop] = trim(implode("\n", $content));
                 $content = array();
             }
             $prop = trim(cut_string_end(cut_string_start($line, '['), ']'));
             continue;
         }
         if (!$prop) {
             continue;
         }
         $content[] = $line;
     }
     if ($prop) {
         $this->props[$prop] = trim(implode("\n", $content));
     }
     return $this->props;
 }
开发者ID:ilivanoff,项目名称:www,代码行数:35,代码来源:TextPropsAdapter.php

示例5: render

 /**
  * @param  \Illuminate\View\View|string|array $view View object or view path
  * @param  array $data Data that should be made available to the view. Only used when $view is a string path
  * @param  string|boolean $layout Master layout path
  *
  * @return \Illuminate\View\View|\Illuminate\Http\Response
  */
 public function render($view, $data = [], $layout = null)
 {
     $format = null;
     if (is_array($view) && count($view) === 1) {
         $format = array_keys($view)[0];
         $view = array_values($view)[0];
         if (!ends_with($view, '_' . $format)) {
             $view = $view . '_' . $format;
         }
     }
     if (is_string($view)) {
         $view = View::make($view, $data);
     }
     // short circuit
     if ($format) {
         $response = Response::make($view);
         $response->header('Content-Type', Request::getMimeType($format));
         return $response;
     }
     if (!is_null($layout)) {
         $this->layout = $layout;
         $this->setupLayout();
     }
     if ($this->layout) {
         $this->layout->content = $view;
         return $this->layout;
     } else {
         return $view;
     }
 }
开发者ID:efficiently,项目名称:jquery-laravel,代码行数:37,代码来源:ControllerAdditions.php

示例6: ensure_trailing_slash

function ensure_trailing_slash($path)
{
    if (!ends_with($path, '/')) {
        return $path . '/';
    }
    return $path;
}
开发者ID:notlion,项目名称:gloomi-lister,代码行数:7,代码来源:util.php

示例7: unwrap

 static function unwrap($token, $domains, $address = null)
 {
     if ($package = base64_decode($token, true)) {
         if ($package = json::decode($package)) {
             if (isset($package->value) and isset($package->domain) and isset($package->expire_at) and isset($package->digest)) {
                 $digest = $package->digest;
                 unset($package->digest);
                 if ($digest === self::digest($package)) {
                     if (isset($package->address)) {
                         if (is_null($address) or $package->address !== $address) {
                             return null;
                         }
                     }
                     if ($package->expire_at === 0 or $package->expire_at > @time()) {
                         foreach ($domains as $domain) {
                             if (ends_with('.' . $package->domain, '.' . $domain)) {
                                 return $package->value;
                             }
                         }
                     }
                 }
             }
         }
     }
     return null;
 }
开发者ID:nyan-cat,项目名称:easyweb,代码行数:26,代码来源:security.php

示例8: handle

 /**
  * Convert a blade view into a site page.
  *
  * @param SplFileInfo $file
  *
  * @return void
  */
 public function handle(SplFileInfo $file, $viewsData)
 {
     $this->viewsData = $viewsData;
     $this->file = $file;
     $this->viewPath = $this->getViewPath();
     $this->directory = $this->getDirectoryPrettyName();
     $this->appendViewInformationToData();
     $content = $this->getFileContent();
     $this->filesystem->put(sprintf('%s/%s', $this->prepareAndGetDirectory(), ends_with($file->getFilename(), ['.blade.php', 'md']) ? 'index.html' : $file->getFilename()), $content);
     // copy images to public folder
     foreach ($file->images as $media) {
         $copyFrom = ORCA_CONTENT_DIR . "/{$file->getRelativePath()}/{$media}";
         $copyTo = "{$this->directory}/{$media}";
         if (!$this->filesystem->copy($copyFrom, $copyTo)) {
             echo "failed to copy {$media}...\n";
         }
     }
     // copy documents
     foreach ($file->documents as $media) {
         $copyFrom = ORCA_CONTENT_DIR . "/{$file->getRelativePath()}/{$media}";
         $copyTo = "{$this->directory}/{$media}";
         if (!$this->filesystem->copy($copyFrom, $copyTo)) {
             echo "failed to copy {$media}...\n";
         }
     }
 }
开发者ID:tao,项目名称:orca,代码行数:33,代码来源:BlogPostHandler.php

示例9: stripExtension

 private function stripExtension($hash)
 {
     if (ends_with($hash, '.png')) {
         return substr($hash, 0, -4);
     }
     return $hash;
 }
开发者ID:noteventhrice,项目名称:duffleimg,代码行数:7,代码来源:MainController.php

示例10: recurse

 /**
  * recurse method
  *
  * @param array  $items
  * @param string $parentId
  */
 protected function recurse($items = [], $parentId = 'root')
 {
     foreach ($items as $item) {
         $link = '#';
         $type = null;
         if (array_key_exists('document', $item)) {
             $type = 'document';
             // remove .md extension if present
             $path = ends_with($item['document'], ['.md']) ? Str::remove($item['document'], '.md') : $item['document'];
             $link = $this->codex->url($this->ref->getProject(), $this->ref->getName(), $path);
         } elseif (array_key_exists('href', $item)) {
             $type = 'href';
             $link = $item['href'];
         }
         $id = md5($item['name'] . $link);
         $node = $this->menu->add($id, $item['name'], $parentId);
         $node->setAttribute('href', $link);
         $node->setAttribute('id', $id);
         if (isset($path)) {
             $node->setMeta('path', $path);
         }
         if (isset($item['icon'])) {
             $node->setMeta('icon', $item['icon']);
         }
         if (isset($item['children'])) {
             $type = 'parent';
         }
         $node->setMeta('type', $type);
         if (isset($item['children'])) {
             $this->recurse($item['children'], $id);
         }
     }
 }
开发者ID:codexproject,项目名称:core,代码行数:39,代码来源:SidebarMenuResolver.php

示例11: __construct

 /**
  * Constructor.
  *
  * Configure path config.
  *
  * @param  string $assetsPath   Base path to assets, within public directory
  * @param  string $manifestPath Full path to asset version manifest
  * @param  string $url          Optional URL prefix for assets
  * @return void
  */
 public function __construct($assetsPath, $manifestPath, $url = null)
 {
     $this->assetsPath = ends_with($assetsPath, '/') ? rtrim($assetsPath, '/') : $assetsPath;
     $this->manifestPath = $manifestPath;
     $this->url = $url;
     $this->manifest = null;
 }
开发者ID:3ev,项目名称:laravel-assets,代码行数:17,代码来源:Loader.php

示例12: opinionated

 /**
  * Register opinionated controllers
  * 
  * @param array		$controllers	the controllers and config
  * @param string	$bundle			the bundle where the controller can be found
  * @param string	$url_prefix		a global url prefix
  * @param string	$route_type		the type of the route (pages or api)
  * @param array		$parents
  */
 public static function opinionated($controllers, $bundle, $url_prefix, $route_type, $parents = array())
 {
     if (!ends_with($url_prefix, '/')) {
         $url_prefix .= '/';
     }
     foreach ($controllers as $controller => $options) {
         list($types, $children) = $options;
         foreach ($types as $type) {
             list($method, $plural, $has_identity, $postfix) = static::$types[$type];
             $segment = $controller;
             $action = ($bundle ? $bundle . '::' : '') . implode('.', $parents) . (count($parents) > 0 ? '.' : '') . $segment . '@' . $type;
             if ($plural) {
                 $segment = Str::plural($segment);
             }
             $prefixes = array_map(function ($parent) {
                 return $parent ? $parent . '/(:any)/' : '(:any)/';
             }, $parents);
             $prefix = implode('', $prefixes);
             $route = $url_prefix . $prefix . $segment . ($has_identity ? '/(:any)' : '') . ($route_type == 'pages' && $postfix ? '/' . $postfix : '');
             if ($route_type == 'pages') {
                 $method = '*';
             }
             Router::register($method, $route, $action);
         }
         $parents[] = $controller;
         if (is_array($children)) {
             static::opinionated($children, $bundle, $url_prefix, $route_type, $parents);
         }
         $parents = array();
     }
 }
开发者ID:reith2004,项目名称:components,代码行数:40,代码来源:route.php

示例13: play

 /**
  * Play/stream a song.
  *
  * @link https://github.com/phanan/koel/wiki#streaming-music
  *
  * @param Song      $song      The song to stream.
  * @param null|bool $transcode Whether to force transcoding the song.
  *                             If this is omitted, by default Koel will transcode FLAC.
  * @param null|int  $bitRate   The target bit rate to transcode, defaults to OUTPUT_BIT_RATE.
  *                             Only taken into account if $transcode is truthy.
  *
  * @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector
  */
 public function play(Song $song, $transcode = null, $bitRate = null)
 {
     if ($song->s3_params) {
         return (new S3Streamer($song))->stream();
     }
     // If `transcode` parameter isn't passed, the default is to only transcode FLAC.
     if ($transcode === null && ends_with(mime_content_type($song->path), 'flac')) {
         $transcode = true;
     }
     $streamer = null;
     if ($transcode) {
         $streamer = new TranscodingStreamer($song, $bitRate ?: config('koel.streaming.bitrate'), request()->input('time', 0));
     } else {
         switch (config('koel.streaming.method')) {
             case 'x-sendfile':
                 $streamer = new XSendFileStreamer($song);
                 break;
             case 'x-accel-redirect':
                 $streamer = new XAccelRedirectStreamer($song);
                 break;
             default:
                 $streamer = new PHPStreamer($song);
                 break;
         }
     }
     $streamer->stream();
 }
开发者ID:phanan,项目名称:koel,代码行数:40,代码来源:SongController.php

示例14: test02EndsWith

 public function test02EndsWith()
 {
     $this->assertTrue(function_exists('ends_with'));
     $this->assertTrue(ends_with('ends_with', 'ith'));
     $this->assertFalse(ends_with('ith', 'ends_with'));
     $this->assertTrue(ends_with('ends_with', ''));
 }
开发者ID:jl9n,项目名称:CuteLib,代码行数:7,代码来源:CommonTest.php

示例15: isPathSupported

 public static function isPathSupported($path)
 {
     $extension = array_first(array_keys(static::$compilers), function ($key, $value) use($path) {
         return ends_with($path, $value);
     });
     return $extension !== null;
 }
开发者ID:shnhrrsn,项目名称:laravel-assets,代码行数:7,代码来源:Asset.php


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