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


PHP Str::contains方法代码示例

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


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

示例1: init

 public static function init()
 {
     if (!static::$initialized) {
         $sessionTimeLimit = 20 * 60;
         session_set_cookie_params($sessionTimeLimit);
         session_start();
         // Verify if session already is valid
         $keyDiscardTime = '___discard_after___';
         $now = time();
         if (isset($_SESSION[$keyDiscardTime]) && $now > $_SESSION[$keyDiscardTime]) {
             // this session has worn out its welcome; kill it and start a brand new one
             session_unset();
             session_destroy();
             session_start();
         }
         // either new or old, it should live at most for another hour
         $_SESSION[$keyDiscardTime] = $now + $sessionTimeLimit;
         static::$initialized = true;
         //Clear all old flash data
         foreach ($_SESSION as $k => $v) {
             if (Str::contains($k, ":old:")) {
                 static::clear($k);
             }
         }
         //Set all new flash data as old, to be cleared on the next request
         foreach ($_SESSION as $k => $v) {
             $parts = explode(":new:", $k);
             if (is_array($parts) && count($parts) == 2) {
                 $newKey = "flash:old:" . $parts[1];
                 static::set($newKey, $v);
                 static::clear($k);
             }
         }
     }
 }
开发者ID:jura-php,项目名称:jura,代码行数:35,代码来源:Session.php

示例2: addAllowedActionsToController

 /**
  * @param string $content
  * @param string $formClass
  *
  * @return string
  */
 protected function addAllowedActionsToController($content, $formClass)
 {
     $allowedActions = 'private static $allowed_actions';
     if (!Str::contains($content, $allowedActions)) {
     }
     return $content;
 }
开发者ID:axyr,项目名称:silverstripe-console,代码行数:13,代码来源:MakeFormCommand.php

示例3: containsAny

 public static function containsAny($haystack, $needles)
 {
     foreach ($needles as $needle) {
         if (Str::contains($haystack, $needle)) {
             return true;
         }
     }
     return false;
 }
开发者ID:ReactiveX,项目名称:RxPHP,代码行数:9,代码来源:utils.php

示例4: parseFunction

 /**
  * Parses custom function calls for geting function name and parameters.
  *
  * @param string $function
  *
  * @return array
  */
 private function parseFunction($function)
 {
     if (!Str::contains($function, ':')) {
         return [$function, []];
     }
     list($function, $params) = explode(':', $function, 2);
     $params = (array) Json::decode($params, true);
     return [$function, $params];
 }
开发者ID:elegantweb,项目名称:framework,代码行数:16,代码来源:FunctionParserTrait.php

示例5: toForm

 /**
  * Dispatch a call over to Form
  *
  * @param string $method     The method called
  * @param array  $parameters Its parameters
  *
  * @return Form
  */
 public function toForm($method, $parameters)
 {
     // Disregards if the method doesn't contain 'open'
     if (!Str::contains($method, 'open') and !Str::contains($method, 'Open')) {
         return false;
     }
     $form = new Form\Form($this->app, $this->app['url'], $this->app['former.populator']);
     return $form->openForm($method, $parameters);
 }
开发者ID:LavaLite,项目名称:framework,代码行数:17,代码来源:MethodDispatcher.php

示例6: getMemberByEmailOrID

 /**
  * @return Member|null
  */
 protected function getMemberByEmailOrID()
 {
     $emailorid = $this->argument('emailorid');
     $member = null;
     if (Str::contains($emailorid, '@')) {
         $member = Member::get()->where("Email = '" . Convert::raw2sql($emailorid) . "'")->first();
     } else {
         $member = Member::get()->byID($emailorid);
     }
     return $member;
 }
开发者ID:axyr,项目名称:silverstripe-console,代码行数:14,代码来源:ResetPasswordCommand.php

示例7: fromReflectionMethod

 public static function fromReflectionMethod(\ReflectionMethod $method)
 {
     $methodName = $method->getName();
     $docComment = $method->getDocComment();
     $reactivexId = extract_doc_annotation($docComment, '@reactivex');
     $demoFiles = extract_doc_annotations($docComment, '@demo');
     $description = extract_doc_description($docComment);
     $isObservable = Str::contains($docComment, '@observable');
     $demos = array_map(function ($path) {
         return Demo::fromPath($path);
     }, $demoFiles);
     return new DocumentedMethod($methodName, $reactivexId, $description, $demos, $isObservable);
 }
开发者ID:ReactiveX,项目名称:RxPHP,代码行数:13,代码来源:doc-loader.php

示例8: getByPath

 /**
  * Get array item by path separated by dots. Example: getByPath('dir.file', ['dir' => ['file' => 'text.txt']]) return "text.txt"
  * @param string $path
  * @param array|null $array
  * @param string $delimiter
  * @return array|string|null
  */
 public static function getByPath($path, $array = null, $delimiter = '.')
 {
     // path of nothing? interest
     if (!Obj::isArray($array) || count($array) < 1) {
         return null;
     }
     // c'mon man, what the f*ck are you doing? ))
     if (!Str::contains($delimiter, $path)) {
         return $array[$path];
     }
     $output = $array;
     $pathArray = explode($delimiter, $path);
     foreach ($pathArray as $key) {
         $output = $output[$key];
     }
     return $output;
 }
开发者ID:phpffcms,项目名称:ffcms-core,代码行数:24,代码来源:Arr.php

示例9: remove

 public static function remove($key, $asMask = false)
 {
     $key = Str::toURIParam($key);
     if (!$asMask) {
         $path = static::$path . $key . ".cache";
         return File::delete($path);
     } else {
         $deleted = false;
         $files = File::lsdir(static::$path, ".cache");
         foreach ($files as $file) {
             if (Str::contains($file, $key)) {
                 File::delete(static::$path . $file);
                 $delete = true;
             }
         }
         return $deleted;
     }
 }
开发者ID:jura-php,项目名称:jura,代码行数:18,代码来源:Cache.php

示例10: parseOption

 /**
  * Parse an option expression.
  *
  * @param string $token
  *
  * @return \Symfony\Component\Console\Input\InputOption
  */
 protected static function parseOption($token)
 {
     $description = null;
     if (Str::contains($token, ' : ')) {
         list($token, $description) = explode(' : ', $token);
         $token = trim($token);
         $description = trim($description);
     }
     $shortcut = null;
     $matches = preg_split('/\\s*\\|\\s*/', $token, 2);
     if (isset($matches[1])) {
         $shortcut = $matches[0];
         $token = $matches[1];
     }
     switch (true) {
         case Str::endsWith($token, '='):
             return new InputOption(trim($token, '='), $shortcut, InputOption::VALUE_OPTIONAL, $description);
         case Str::endsWith($token, '=*'):
             return new InputOption(trim($token, '=*'), $shortcut, InputOption::VALUE_OPTIONAL | InputOption::VALUE_IS_ARRAY, $description);
         case preg_match('/(.+)\\=(.+)/', $token, $matches):
             return new InputOption($matches[1], $shortcut, InputOption::VALUE_OPTIONAL, $description, $matches[2]);
         default:
             return new InputOption($token, $shortcut, InputOption::VALUE_NONE, $description);
     }
 }
开发者ID:axyr,项目名称:silverstripe-console,代码行数:32,代码来源:Parser.php

示例11: validateKey

 /**
  * Validates the cache item key according to PSR-6.
  *
  * @param string $key Cache item key
  *
  * @throws \Elegant\Cache\Exception\InvalidArgumentException For invalid key
  */
 public static final function validateKey($key)
 {
     if (Str::contains($key, ['{', '}', '(', ')', '/', '\\', '@', ':'])) {
         throw new InvalidArgumentException(sprintf('Invalid key "%s" provided; contains reserved characters "{}()/\\@:".', $key));
     }
 }
开发者ID:elegantweb,项目名称:framework,代码行数:13,代码来源:CacheItem.php

示例12: str_contains

 /**
  * Determine if a given string contains a given substring.
  *
  * @param  string  $haystack
  * @param  string|array  $needles
  * @return bool
  */
 function str_contains($haystack, $needles)
 {
     return Str::contains($haystack, $needles);
 }
开发者ID:runningjack,项目名称:busticketAPI1,代码行数:11,代码来源:helpers.php

示例13: foreach

    $options = [0 => 'Ninguna'];
    foreach ($tmp as $key => $value) {
        $options[$key] = $value;
    }
    return Form::selectFormGroup($name, $options, $title, $formname, $attributes);
});
Form::macro('theMediaFormGroup', function ($name, $title, $formname, $attributes) {
    $options = ['Televisión', 'Periódico', 'Radio', 'Otro'];
    return Form::selectFormGroup($name, $options, $title, $formname, $attributes);
});
Form::macro('selectFormGroup', function ($name, $options, $title, $formname, $attr) {
    return "\n" . '<div class="form-group"' . "\n" . '	ng-class="{\'has-error\' : film_form.' . $name . '.$invalid }">' . "\n" . '	<label for="' . $name . '" class="col-sm-2 control-label text-right">' . $title . '</label>' . "\n" . '	<div class="col-sm-10">' . "\n" . Form::select($name, $options, null, $attr) . '	</div>' . "\n" . '</div>' . "\n";
});
/**
 * By default all the text area inputs have the widget CKEditor.
 *
 * If you do not want the CKEditor you must set the $attr['class'] = 'no-ckeditor'.
 */
Form::macro('textareaFormGroup', function ($name, $title, $formname, $attr) {
    $attr['class'] = isset($attr['class']) ? $attr['class'] : '';
    /**
     * If it does not has a ckeditor class then we add a full editor.
     */
    if (!Str::contains($attr['class'], 'ckeditor')) {
        $attr['class'] .= ' ckeditor-full';
    }
    return Form::wrapperInput($name, $title, Form::textarea($name, null, $attr));
});
Form::macro('wrapperInput', function ($name, $title, $input) {
    return "\n" . '<div class="form-group">' . "\n" . '	<label for="' . $name . '" class="col-sm-2 control-label text-right">' . $title . '</label>' . "\n" . '	<div class="col-sm-10">' . "\n" . '	' . $input . "\n" . '	</div>' . "\n" . '</div>' . "\n";
});
开发者ID:filmoteca,项目名称:filmoteca,代码行数:31,代码来源:form.macros.php

示例14: hasFlag

 public function hasFlag($flag)
 {
     return Str::contains($this->flags, $flag);
 }
开发者ID:jura-php,项目名称:jura,代码行数:4,代码来源:Field.php

示例15: build_code_samples

function build_code_samples(Demo $demo)
{
    $lines = explode("\n", $demo->demoCode);
    $start = -1;
    foreach ($lines as $position => $line) {
        if (Str::contains($line, 'require_once')) {
            $start = $position;
            break;
        }
    }
    array_splice($lines, 0, $start + 2);
    $demoCode = implode("\n", $lines);
    $url = $demo->getURL();
    return <<<DEMO
<div class="code php">
    <pre>
//from {$url}

{$demoCode}
   </pre>
</div>
<div class="output">
    <pre>
{$demo->demoOutput}
    </pre>
</div>
DEMO;
}
开发者ID:ReactiveX,项目名称:RxPHP,代码行数:28,代码来源:doc-writer.php


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