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


PHP str_is函数代码示例

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


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

示例1: handle

 /**
  * Handle the command.
  *
  * @return array
  */
 public function handle()
 {
     $options = [];
     $group = null;
     foreach (explode("\n", $this->options) as $option) {
         // Find option [groups]
         if (starts_with($option, '[')) {
             $group = trans(substr(trim($option), 1, -1));
             $options[$group] = [];
             continue;
         }
         // Split on the first ":"
         if (str_is('*:*', $option)) {
             $option = explode(':', $option, 2);
         } else {
             $option = [$option, $option];
         }
         $key = ltrim(trim(array_shift($option)));
         $value = ltrim(trim($option ? array_shift($option) : $key));
         if ($group) {
             $options[$group][$key] = $value;
         } else {
             $options[$key] = $value;
         }
     }
     return $options;
 }
开发者ID:visualturk,项目名称:select-field_type,代码行数:32,代码来源:ParseOptions.php

示例2: login_callback

 /**
  * Obtain the user information from GitHub.
  *
  * @return Response
  */
 public function login_callback($provider)
 {
     switch (strtolower($provider)) {
         case 'facebook':
         case 'twitter':
             $user_sso = Socialite::driver(strtolower($provider))->user();
             if (str_is(strtolower($provider), 'facebook')) {
                 $result = $this->dispatch(new CreateMemberFromFacebook($user_sso));
             } else {
                 $result = $this->dispatch(new CreateMemberFromTwitter($user_sso));
             }
             if ($result['status'] == 'success') {
                 Auth::login($result['data']['data']);
                 if ($result['data']['data']->is_complete) {
                     if (Session::has('redirect')) {
                         $redirect = Session::get('redirect', route('web.home'));
                         Session::remove('redirect');
                         return redirect()->to($redirect);
                     } else {
                         return redirect()->route('web.home');
                     }
                 } else {
                     return redirect()->route('web.me.profile.complete');
                 }
             } else {
                 return redirect()->route('web.login')->withErrors($result['data']['message']);
             }
             break;
         default:
             App::abort(404);
             break;
     }
 }
开发者ID:ThunderID,项目名称:capcus.v2,代码行数:38,代码来源:AuthController.php

示例3: is

 /**
  * Get current state.
  *
  * @return boolean 
  */
 public function is()
 {
     $this->routes = array();
     foreach (func_get_args() as $param) {
         if (!is_array($param)) {
             $this->routes[] = $param;
             continue;
         }
         foreach ($param as $p) {
             $this->routes[] = $p;
         }
     }
     $this->request = Request::path();
     $this->parseRoutes();
     foreach ($this->routes as $route) {
         if (!Request::is($route)) {
             continue;
         }
         foreach ($this->bad_routes as $bad_route) {
             if (str_is($bad_route, $this->request)) {
                 return false;
             }
         }
         return true;
     }
     return false;
 }
开发者ID:digithis,项目名称:activehelper,代码行数:32,代码来源:Activehelper.php

示例4: __construct

 function __construct()
 {
     ////////
     // Me //
     ////////
     $this->me = null;
     ///////////////////
     // Init Template //
     ///////////////////
     $this->version = env('WEB_VERSION', 'default');
     $this->layout = view($this->version . '.templates.html');
     //////////////
     // Init API //
     //////////////
     $this->api_url = $this->layout->api_url = env('API_URL', 'http://capcusapi');
     $this->api = new \GuzzleHttp\Client(['base_url' => $this->api_url]);
     ////////////////
     // Init Alert //
     ////////////////
     foreach (Session::all() as $k => $v) {
         if (str_is('_alert_*', $k)) {
             $this->layout->{$k} = $v;
         }
     }
 }
开发者ID:erickmo,项目名称:CapcusCmsV3,代码行数:25,代码来源:Controller.php

示例5: post_login

 function post_login()
 {
     $input = request()->input();
     ///////////////////////
     // Validate remotely //
     ///////////////////////
     $data['email'] = $input['username'];
     $data['password'] = $input['password'];
     $data['grant_type'] = 'password';
     $data['key'] = env('CAPCUS_API_KEY', 'qwerty123');
     $data['secret'] = env('CAPCUS_API_SECRET', 'qwerty123');
     $api_response = json_decode($this->api->post($this->api_url . '/authorized/client', ['form_params' => $data])->getBody());
     //////////////
     // redirect //
     //////////////
     if (str_is('success', $api_response->status)) {
         foreach ($api_response->data->whoami->auths as $key => $value) {
             if (str_is('cms', $value->app)) {
                 Session::put('access_token', $api_response->data->access_token);
                 Session::put('refresh_token', $api_response->data->refresh_token);
                 Session::put('expired_at', $api_response->data->expired_at);
                 Session::put('me', $api_response->data->whoami);
                 Session::put('auth_cms', $value->roles);
                 return redirect()->intended(route('dashboard'));
             }
         }
     }
     return redirect()->back()->withErrors(new MessageBag(['auth' => "Unauthorized Access"]));
 }
开发者ID:erickmo,项目名称:CapcusCmsV3,代码行数:29,代码来源:LoginController.php

示例6: __get

 /**
  * Dynamically access the user's attributes.
  *
  * @param  string  $key
  * @return mixed
  */
 public function __get($key)
 {
     if (str_is($key, 'id')) {
         return (string) $this->attributes['_id'];
     }
     return $this->attributes[$key];
 }
开发者ID:sahilsarpal15,项目名称:mongo,代码行数:13,代码来源:MongoUser.php

示例7: detectEnvironment

 /**
  * Detect the application's current environment.
  *
  * @param  array|string $environments
  *
  * @return string
  */
 public function detectEnvironment($environments)
 {
     $args = isset($_SERVER['argv']) ? $_SERVER['argv'] : null;
     if (php_sapi_name() == 'cli' && !is_null($value = $this->getEnvironmentArgument($args))) {
         //running in console and env param is set
         return $this['env'] = head(array_slice(explode('=', $value), 1));
     } else {
         //running as the web app
         if ($environments instanceof Closure) {
             // If the given environment is just a Closure, we will defer the environment check
             // to the Closure the developer has provided, which allows them to totally swap
             // the webs environment detection logic with their own custom Closure's code.
             return $this['env'] = call_user_func($environments);
         } elseif (is_array($environments)) {
             foreach ($environments as $environment => $hosts) {
                 // To determine the current environment, we'll simply iterate through the possible
                 // environments and look for the host that matches the host for this request we
                 // are currently processing here, then return back these environment's names.
                 foreach ((array) $hosts as $host) {
                     if (str_is($host, gethostname())) {
                         return $this['env'] = $environment;
                     }
                 }
             }
         } elseif (is_string($environments)) {
             return $this['env'] = $environments;
         }
     }
     return $this['env'] = 'production';
 }
开发者ID:Alim-ifresco,项目名称:project1.dev4.why.sr,代码行数:37,代码来源:Application.php

示例8: updated

 public function updated($model)
 {
     if (!str_is($model->{$model->getPathField()}, $model->getOriginal($model->getPathField()))) {
         foreach ($model->children as $x) {
             $x->save();
         }
     }
 }
开发者ID:ThunderID,项目名称:capcus.v2,代码行数:8,代码来源:TreeObserver.php

示例9: __call

 public function __call($method, $parameters)
 {
     if (str_is('show*', $method)) {
         $alias = mb_strtolower(substr($method, 4));
         return $this->pageCreateView($this->context, $alias);
     }
     throw new BadMethodCallException("Method [{$method}] does not exist.");
 }
开发者ID:jetcms,项目名称:website,代码行数:8,代码来源:PageController.php

示例10: testStrIs

 public function testStrIs()
 {
     $this->assertTrue(str_is('*.dev', 'localhost.dev'));
     $this->assertTrue(str_is('a', 'a'));
     $this->assertTrue(str_is('*dev*', 'localhost.dev'));
     $this->assertFalse(str_is('*something', 'foobar'));
     $this->assertFalse(str_is('foo', 'bar'));
 }
开发者ID:hochanh,项目名称:Bootsoft-Bowling,代码行数:8,代码来源:HelpersTest.php

示例11: allowRules

 public function allowRules($rule)
 {
     $allow = array_first($this->getRules(), function ($index, $instance) use($rule) {
         if (str_is($instance, $rule)) {
             return true;
         }
     });
     return $allow !== null;
 }
开发者ID:bitw,项目名称:acl-example,代码行数:9,代码来源:User.php

示例12: checkPattern

 /**
  * @param $incoming
  * @param $target
  * @return bool
  */
 protected function checkPattern($incoming, $target)
 {
     if ($this->{$target} !== '*') {
         if (!str_is($this->{$target}, $incoming) && !str_is($incoming, $this->{$target})) {
             return false;
         }
     }
     return true;
 }
开发者ID:ryanhungate,项目名称:api,代码行数:14,代码来源:Scope.php

示例13: isActiveItem

 /**
  * Determine whether the given item is currently active.
  * @param  array   $item
  * @param  string  $url
  * @return bool
  */
 protected function isActiveItem(array $item, $url)
 {
     foreach ($item['active'] as $active) {
         if (str_is($active, $url)) {
             return true;
         }
     }
     return false;
 }
开发者ID:jacobDaeHyung,项目名称:laravel-tricks,代码行数:15,代码来源:Builder.php

示例14: normalize

 /**
  * Normalize button input.
  *
  * @param TreeBuilder $builder
  */
 public function normalize(TreeBuilder $builder)
 {
     $buttons = $builder->getButtons();
     foreach ($buttons as $key => &$button) {
         /*
          * If the button is a string then use
          * it as the button parameter.
          */
         if (is_string($button)) {
             $button = ['button' => $button];
         }
         /*
          * If the key is a string and the button
          * is an array without a button param then
          * move the key into the button as that param.
          */
         if (!is_integer($key) && !isset($button['button'])) {
             $button['button'] = $key;
         }
         /*
          * Make sure some default parameters exist.
          */
         $button['attributes'] = array_get($button, 'attributes', []);
         /*
          * Move the HREF if any to the attributes.
          */
         if (isset($button['href'])) {
             array_set($button['attributes'], 'href', array_pull($button, 'href'));
         }
         /*
          * Move the target if any to the attributes.
          */
         if (isset($button['target'])) {
             array_set($button['attributes'], 'target', array_pull($button, 'target'));
         }
         /*
          * Move all data-* keys
          * to attributes.
          */
         foreach ($button as $attribute => $value) {
             if (str_is('data-*', $attribute)) {
                 array_set($button, 'attributes.' . $attribute, array_pull($button, $attribute));
             }
         }
         /*
          * Make sure the HREF is absolute.
          */
         if (isset($button['attributes']['href']) && is_string($button['attributes']['href']) && !starts_with($button['attributes']['href'], 'http')) {
             $button['attributes']['href'] = url($button['attributes']['href']);
         }
         /*
          * Use small buttons for trees.
          */
         $button['size'] = array_get($button, 'size', 'xs');
     }
     $builder->setButtons($buttons);
 }
开发者ID:huglester,项目名称:streams-platform,代码行数:62,代码来源:ButtonNormalizer.php

示例15: getImageGalleryAttribute

 function getImageGalleryAttribute()
 {
     foreach ($this->images as $image) {
         if (str_is('gallery*', strtolower($image->name))) {
             $galleries[] = $image;
         }
     }
     return $galleries;
 }
开发者ID:ThunderID,项目名称:capcus.v2,代码行数:9,代码来源:HasManyImagesTrait.php


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