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


PHP starts_with函数代码示例

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


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

示例1: init

 public function init($initialiser = null)
 {
     $toolbarConfig = $this->config("bundl\\debugtoolbar");
     $baseUrl = $toolbarConfig->getStr("base_url", '/_debugbar');
     if (starts_with($baseUrl, '/')) {
         $passthroughs = $this->config("dispatch")->getArr("passthrough");
         if (!isset($passthroughs[substr($baseUrl, 1)])) {
             throw new \Exception("Please add the following to your defaults.ini within [dispatch]\n" . "passthrough[" . substr($baseUrl, 1) . "] = " . "../vendor/maximebf/debugbar/src/DebugBar/Resources");
         }
     }
     EventManager::listen(EventManager::CUBEX_WEBPAGE_RENDER_BODY, [$this, "renderBody"]);
     EventManager::listen(EventManager::CUBEX_WEBPAGE_RENDER_HEAD, [$this, "renderHead"]);
     EventManager::listen(EventManager::CUBEX_LOG, [$this, "catchLog"]);
     $this->_debugBar = new DebugBar();
     $this->_debugBar->addCollector(new PhpInfoCollector());
     $this->_debugBar->addCollector(new MessagesCollector());
     $this->_debugBar->addCollector(new TranslationDataCollector());
     $this->_debugBar->addCollector(new RequestDataCollector());
     $this->_debugBar->addCollector(new CubexCoreTimeData());
     $this->_debugBar->addCollector(new CassandraDataCollector());
     $this->_debugBar->addCollector(new QueryDataCollector());
     $this->_debugBar->addCollector(new MemoryCollector());
     $this->_debugBar->addCollector(new ExceptionsCollector());
     $this->_debugRender = $this->_debugBar->getJavascriptRenderer();
     $this->_debugRender->setBaseUrl($baseUrl);
 }
开发者ID:bundl,项目名称:debugtoolbar,代码行数:26,代码来源:DebugToolbarBundl.php

示例2: loadLaravelRoutes

 /**
  * Load the Laravel routes into the application routes for
  * permission assignment.
  *
  * @param $routeNameRegEx
  *
  * @return int The number of Laravel routes loaded.
  */
 public static function loadLaravelRoutes($routeNameRegEx)
 {
     $AppRoutes = \Route::getRoutes();
     $cnt = 0;
     foreach ($AppRoutes as $appRoute) {
         $name = $appRoute->getName();
         $methods = $appRoute->getMethods();
         $path = $appRoute->getPath();
         $actionName = $appRoute->getActionName();
         // Skip AuthController and PasswordController routes, Those are always authorized.
         if (!str_contains($actionName, 'AuthController') && !str_contains($actionName, 'PasswordController')) {
             // Include only if the name matches the requested Regular Expression.
             if (preg_match($routeNameRegEx, $name)) {
                 foreach ($methods as $method) {
                     $route = null;
                     if ('HEAD' !== $method && !starts_with($path, '_debugbar')) {
                         // Skip all DebugBar routes.
                         // TODO: Use Repository 'findWhere' when its fixed!!
                         //                    $route = $this->route->findWhere([
                         //                        'method'      => $method,
                         //                        'action_name' => $actionName,
                         //                    ])->first();
                         $route = \App\Models\Route::ofMethod($method)->ofActionName($actionName)->ofPath($path)->first();
                         if (!isset($route)) {
                             $cnt++;
                             Route::create(['name' => $name, 'method' => $method, 'path' => $path, 'action_name' => $actionName, 'enabled' => 1]);
                         }
                     }
                 }
             }
         }
     }
     return $cnt;
 }
开发者ID:sroutier,项目名称:laravel-5.1-enterprise-starter-kit,代码行数:42,代码来源:Route.php

示例3: testAllRoutesHaveAuthorization

 /**
  * Tests that the authorization method is attached to all routes except for the / and /home
  *
  */
 public function testAllRoutesHaveAuthorization()
 {
     $routesArr = Route::getRoutes();
     //get all routes
     foreach ($routesArr as $route) {
         $path = $route->getPath();
         // Log::info('testing route ' . $path);
         $vals = array_values($route->middleware());
         $found = false;
         foreach ($vals as $index => $el) {
             if (FALSE !== strpos($el, "auth")) {
                 $found = true;
                 break;
             }
         }
         /**
                     Temporary hack to handle resource routes until we finish the api
                      *
                      **/
         if (starts_with($route->getPath(), "api")) {
             $found = true;
         }
         if ('/' === $path || 'home' === $path || 'index.php' === $path || 'mainlogin' === $path || 'register' === $path || 'login' === $path || 'forgotpassword' === $path) {
             $this->assertFalse($found);
         } else {
             $this->assertTrue($found, 'Route: ' . $route->getPath() . ' doesn\'t have the Authorize middleware attached (keyword \'auth\' not found in middleware array)');
         }
     }
 }
开发者ID:northdpole,项目名称:laravelTest,代码行数:33,代码来源:AuthorizationControllerTest.php

示例4: handle

 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Closure  $next
  * @return mixed
  */
 public function handle($request, Closure $next)
 {
     if (!starts_with($request->getClientIp(), '192.168.0')) {
         $this->analysis();
     }
     return $next($request);
 }
开发者ID:picolit,项目名称:bbs,代码行数:14,代码来源:RequestAnalysis.php

示例5: evaluateOne

 public function evaluateOne($text, $dependencies = [])
 {
     $parts = explode('>', $text);
     if (count($parts) < 2) {
         return '';
     }
     if ($parts[0] == 'Dict') {
         $default = '';
         $item = $this->getOneDict($parts[1], $default);
         if (count($parts) == 3) {
             $array = array_dot($item->toArray());
             if (!array_key_exists($parts[2], $array)) {
                 return '';
             }
             return $array[$parts[2]];
         }
         return $item;
     } else {
         $identifier = $parts[1];
         if (starts_with($identifier, ':')) {
             $identifier = str_replace(':', '', $identifier);
             $identifier = $dependencies[$identifier];
         }
         $item = $this->getOneEntity($parts[0], $identifier);
         if (!$item) {
             return '';
         }
         $array = array_dot($item->toArray());
         if (!array_key_exists($parts[2], $array)) {
             return '';
         }
         return $array[$parts[2]];
     }
 }
开发者ID:joadr,项目名称:cms,代码行数:34,代码来源:Engine.php

示例6: load

 /**
  * Load the file corresponding to a given class.
  *
  * This method is registerd in the bootstrap file as an SPL auto-loader.
  *
  * @param  string  $class
  * @return void
  */
 public static function load($class)
 {
     // First, we will check to see if the class has been aliased. If it has,
     // we will register the alias, which may cause the auto-loader to be
     // called again for the "real" class name to load its file.
     if (isset(static::$aliases[$class])) {
         class_alias(static::$aliases[$class], $class);
     } elseif (isset(static::$mappings[$class])) {
         require static::$mappings[$class];
         return;
     }
     // If the class namespace is mapped to a directory, we will load the
     // class using the PSR-0 standards from that directory accounting
     // for the root of the namespace by trimming it off.
     foreach (static::$namespaces as $namespace => $directory) {
         if (starts_with($class, $namespace)) {
             return static::load_namespaced($class, $namespace, $directory);
         }
     }
     // If the class uses PEAR-ish style underscores for indicating its
     // directory structure we'll load the class using PSR-0 standards
     // standards from that directory, trimming the root.
     foreach (static::$underscored as $prefix => $directory) {
         if (starts_with($class, $prefix)) {
             return static::load_namespaced($class, $prefix, $directory);
         }
     }
     // If all else fails we will just iterator through the mapped
     // PSR-0 directories looking for the class. This is the last
     // resort and slowest loading option for the class.
     static::load_psr($class);
 }
开发者ID:victoroliveira1605,项目名称:Laravel-Bootstrap,代码行数:40,代码来源:autoloader.php

示例7: getUserId

 /**
  * parse username to get userid
  * 
  */
 protected function getUserId($username)
 {
     if (starts_with($username, "@:")) {
         return substr($username, 2);
     }
     return \Veer\Models\User::where('username', '=', substr($username, 1))->pluck('id');
 }
开发者ID:artemsk,项目名称:veer-core,代码行数:11,代码来源:MessageTraits.php

示例8: env

/**
 * Gets the value of an environment variable. Supports boolean, empty and null.
 * @param  string  $key
 * @param  mixed   $default
 * @return mixed
 */
function env($key, $default = null)
{
    $value = getenv($key);
    if ($value === false) {
        return value($default);
    }
    switch (strtolower($value)) {
        case 'true':
        case '(true)':
            return true;
        case 'false':
        case '(false)':
            return false;
        case 'empty':
        case '(empty)':
            return '';
        case 'null':
        case '(null)':
            return;
    }
    if (strlen($value) > 1 && starts_with($value, '"') && str_finish($value, '"')) {
        return substr($value, 1, -1);
    }
    return $value;
}
开发者ID:visavi,项目名称:rotorcms,代码行数:31,代码来源:helpers.php

示例9: configAssetUrl

 /**
  * Generate a URL to an application asset.
  *
  * @param  string  $path
  * @param  bool    $secure
  * @return string
  */
 protected function configAssetUrl($path, $secure = null)
 {
     static $assetUrl;
     // Remove this.
     $i = 'index.php';
     if (URL::isValidUrl($path)) {
         return $path;
     }
     // Finding asset url config.
     if (is_null($assetUrl)) {
         $assetUrl = \Config::get('theme.assetUrl', '');
     }
     // Using asset url, if available.
     if ($assetUrl) {
         $base = rtrim($assetUrl, '/');
         // Asset URL without index.
         $basePath = str_contains($base, $i) ? str_replace('/' . $i, '', $base) : $base;
     } else {
         if (is_null($secure)) {
             $scheme = Request::getScheme() . '://';
         } else {
             $scheme = $secure ? 'https://' : 'http://';
         }
         // Get root URL.
         $root = Request::root();
         $start = starts_with($root, 'http://') ? 'http://' : 'https://';
         $root = preg_replace('~' . $start . '~', $scheme, $root, 1);
         // Asset URL without index.
         $basePath = str_contains($root, $i) ? str_replace('/' . $i, '', $root) : $root;
     }
     return $basePath . '/' . $path;
 }
开发者ID:fabriciorabelo,项目名称:laravel-theme,代码行数:39,代码来源:AssetContainer.php

示例10: initForm

 protected function initForm($model)
 {
     $this->html = "";
     $this->model = $model;
     foreach ($this->model->getFieldSpec() as $key => $property) {
         if (starts_with($key, 'seo') && $this->showSeo or !starts_with($key, 'seo') && !$this->showSeo) {
             $this->formModelHandler($property, $key, $this->model->{$key});
         }
     }
     if (isset($this->model->translatedAttributes) && count($this->model->translatedAttributes) > 0) {
         $this->model->fieldspec = $this->model->getFieldSpec();
         foreach (config('app.locales') as $locale => $value) {
             if (config('app.locale') != $locale) {
                 $target = "language_box_" . str_slug($value) . "_" . str_random(160);
                 $this->html .= $this->containerLanguage($value, $target);
                 $this->html .= "<div class=\"collapse\" id=\"" . $target . "\">";
                 foreach ($this->model->translatedAttributes as $attribute) {
                     $value = isset($this->model->translate($locale)->{$attribute}) ? $this->model->translate($locale)->{$attribute} : '';
                     $this->property = $this->model->fieldspec[$attribute];
                     if (starts_with($attribute, 'seo') && $this->showSeo or !starts_with($attribute, 'seo') && !$this->showSeo) {
                         $this->formModelHandler($this->model->fieldspec[$attribute], $attribute . '_' . $locale, $value);
                     }
                 }
                 $this->html .= "</div>";
             }
         }
     }
 }
开发者ID:marcoax,项目名称:laraCms,代码行数:28,代码来源:AdminForm.php

示例11: summary

 public static function summary(Account $account)
 {
     // create 3 months range : this month and 2 months before
     $months = [];
     foreach (range(0, 2) as $val) {
         $months[] = date('Y-m', strtotime('-' . $val . ' months'));
     }
     sort($months);
     $range = [$months[0] . date('-01 00:00:00'), $months[count($months) - 1] . date('-d H:i:s')];
     $ledger = $account->ledgers()->whereBetween('created_at', $range)->get(['created_at', 'debit', 'credit', 'balance'])->toArray();
     if (!count($ledger)) {
         return [];
     }
     // $months = array_flip($months);
     foreach ($months as $monthsKey => $month) {
         $month_data = ['debit' => 0, 'credit' => 0, 'balance' => 0, 'month' => date('M Y', strtotime($month . '-01'))];
         foreach ($ledger as $ledgerKey => $transaction) {
             if (!starts_with($transaction['created_at'], $month)) {
                 continue;
             }
             $month_data['debit'] += $transaction['debit'] / 100;
             $month_data['credit'] += $transaction['credit'] / 100;
             $month_data['balance'] = $transaction['balance'] / 100;
         }
         $months[$monthsKey] = $month_data;
     }
     return $months;
 }
开发者ID:wzulfikar,项目名称:eloquent-simple-ledger,代码行数:28,代码来源:LedgerHelper.php

示例12: put

 /**
  * Put a breadcrumb into the collection.
  *
  * @param string $key
  * @param string $value
  */
 public function put($key, $value)
 {
     if (!starts_with($value, 'http')) {
         $value = url($value);
     }
     parent::put($key, $value);
 }
开发者ID:jacksun101,项目名称:streams-platform,代码行数:13,代码来源:BreadcrumbCollection.php

示例13: registerHandlers

 /**
  * Register the handlers for the client.
  *
  * @param array $handlers
  */
 public function registerHandlers(array $handlers = [])
 {
     foreach ($handlers as $handlerClass => $configuration) {
         // If the handler takes a configuration, load that from the array and
         // build the class. If not, then just build the class.
         if (is_numeric($handlerClass)) {
             $handlerClass = $configuration;
             $class = new $handlerClass();
         } else {
             $class = new $handlerClass($configuration);
         }
         // Use reflection to figure out what Elasticsearch methods the handler handles.
         $reflect = new ReflectionClass($class);
         // Find the handled methods and merge them into the client's list.
         $classMethods = $reflect->getMethods(ReflectionMethod::IS_PUBLIC);
         array_walk($classMethods, function ($classMethod) use($handlerClass) {
             if (starts_with($classMethod->name, 'handle')) {
                 $method = lcfirst(substr($classMethod->name, 6));
                 $this->handledMethods[$method][] = $handlerClass;
             }
         });
         // Save the handler instance.
         $this->handlers[$handlerClass] = $class;
     }
     // Boot all the handlers with the client instance.
     foreach ($this->handlers as $handler) {
         $handler->boot($this);
     }
 }
开发者ID:cviebrock,项目名称:laravel-elasticsearch-handlers,代码行数:34,代码来源:Client.php

示例14: __call

 /**
  * Dynamically bind parameters to the view.
  *
  * @param  string $method
  * @param  array  $parameters
  * @return View
  * @throws \BadMethodCallException
  */
 public function __call($method, $parameters)
 {
     if (starts_with($method, 'using')) {
         return $this->using(snake_case(substr($method, 5)));
     }
     return parent::__call($method, $parameters);
 }
开发者ID:visualturk,项目名称:lexicon,代码行数:15,代码来源:View.php

示例15: __call

 public function __call($method, $parameters)
 {
     if (starts_with($method, 'with')) {
         return $this->with(snake_case(substr($method, 4)), $parameters[0]);
     }
     throw new BadMethodCallException("方法 [{$method}] 不存在!.");
 }
开发者ID:fifths,项目名称:lit,代码行数:7,代码来源:View.php


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