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


PHP str::contains方法代码示例

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


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

示例1: crawl

 function crawl()
 {
     $path = url::strip_query($this->raw);
     $path = (array) str::split($path, '/');
     if (a::first($path) == 'index.php') {
         array_shift($path);
     }
     // parse params
     foreach ($path as $p) {
         if (str::contains($p, ':')) {
             $parts = explode(':', $p);
             if (count($parts) < 2) {
                 continue;
             }
             $this->params->{$parts}[0] = $parts[1];
         } else {
             $this->path->_[] = $p;
         }
     }
     // get the extension from the last part of the path
     $this->extension = f::extension($this->path->last());
     if ($this->extension != false) {
         // remove the last part of the path
         $last = array_pop($this->path->_);
         $this->path->_[] = f::name($last);
     }
     return $this->path;
 }
开发者ID:narrenfrei,项目名称:kirbycms,代码行数:28,代码来源:uri.php

示例2: testContains

 public function testContains()
 {
     $this->assertTrue(str::contains($this->sample, 'Äwesøme'));
     $this->assertTrue(str::contains($this->sample, 'äwesøme'));
     // don't ignore upper/lowercase
     $this->assertFalse(str::contains($this->sample, 'äwesøme', false));
     // check for something which isn't there
     $this->assertFalse(str::contains($this->sample, 'Peter'));
 }
开发者ID:aoimedia,项目名称:kosmonautensofa,代码行数:9,代码来源:StrTest.php

示例3: entry

 /**
  * Returns a registry entry object by type
  * 
  * @param string $type
  * @param string $subtype
  * @return Kirby\Registry\Entry
  */
 public function entry($type, $subtype = null)
 {
     $class = 'kirby\\registry\\' . $type;
     if (!class_exists('kirby\\registry\\' . $type)) {
         if (str::contains($type, '::')) {
             $parts = str::split($type, '::');
             $subtype = $parts[0];
             $type = $parts[1];
             return $this->entry($type, $subtype);
         }
         throw new Exception('Unsupported registry entry type: ' . $type);
     }
     return new $class($this, $subtype);
 }
开发者ID:kgchoy,项目名称:main-portfolio-website,代码行数:21,代码来源:registry.php

示例4: run

 public function run()
 {
     if (empty($this->query) or str::length($this->query) <= 1) {
         return false;
     }
     $data = $this->data();
     foreach ($data['pages'] as $page) {
         if (str::contains($page['title'], $this->query) or str::contains($page['uri'], $this->query)) {
             $this->pages->append($page['uri'], $page);
         }
     }
     foreach ($data['users'] as $user) {
         if (str::contains($user['username'], $this->query) or str::contains($user['email'], $this->query)) {
             $this->users->append($user['username'], $user);
         }
     }
     $this->pages = $this->pages->limit(5);
     $this->users = $this->users->limit(5);
 }
开发者ID:irenehilber,项目名称:kirby-base,代码行数:19,代码来源:search.php

示例5: start

 public function start()
 {
     $src = get('source');
     $target = get('target');
     if (!v::url($src)) {
         throw new Exception('Invalid source');
     }
     if (!v::url($target)) {
         throw new Exception('Invalid target');
     }
     if (!str::contains($target, site()->url())) {
         throw new Exception('Invalid target');
     }
     require_once dirname(__DIR__) . DS . 'vendor' . DS . 'mf2.php';
     require_once dirname(__DIR__) . DS . 'vendor' . DS . 'comments.php';
     $data = \Mf2\fetch($src);
     $result = \IndieWeb\comments\parse($data['items'][0], $src);
     if (empty($result)) {
         throw new Exception('Probably spam');
     }
     $path = ltrim(str_replace(site()->url(), '', $target), '/');
     if (!empty($path) and $page = page($path)) {
         if (!empty($result['published'])) {
             $time = strtotime($result['published']);
         } else {
             $time = time();
             $result['published'] = date('c');
         }
         $json = json_encode($result);
         $hash = sha1($json);
         $file = $page->root() . DS . '.webmentions' . DS . $time . '-' . $hash . '.json';
         f::write($file, $json);
         return true;
     } else {
         throw new Exception('Invalid page');
     }
 }
开发者ID:aizlewood,项目名称:2016,代码行数:37,代码来源:endpoint.php

示例6: trigger

 public function trigger($url)
 {
     $response = remote::get($url);
     $html = $response->content();
     if (preg_match_all('!\\<link(.*?)\\>!i', $html, $links)) {
         foreach ($links[0] as $link) {
             if (!str::contains($link, 'rel="webmention"')) {
                 continue;
             }
             if (!preg_match('!href="(.*?)"!', $link, $match)) {
                 continue;
             }
             $endpoint = $match[1];
             $src = $this->page->url();
             $target = $url;
             // invalid endpoint
             if (!v::url($endpoint)) {
                 continue;
             }
             remote::post($endpoint, array('data' => array('source' => $src, 'target' => $target)));
             return $endpoint;
         }
     }
 }
开发者ID:aizlewood,项目名称:2016,代码行数:24,代码来源:mentions.php

示例7: js

function js($url)
{
    $url = str::contains($url, 'http://') || str::contains($url, 'https://') ? $url : url(ltrim($url, '/'));
    return '<script type="text/javascript" src="' . $url . '"></script>' . "\n";
}
开发者ID:robeam,项目名称:kirbycms,代码行数:5,代码来源:helpers.php

示例8: checkUpload

 protected function checkUpload($file, $blueprint)
 {
     if (strtolower($file->extension()) == kirby()->option('content.file.extension', 'txt')) {
         throw new Exception('Content files cannot be uploaded');
     } else {
         if (strtolower($file->extension()) == 'php' or str::contains($file->extension(), 'php') or in_array($file->mime(), f::$mimes['php'])) {
             throw new Exception('PHP files cannot be uploaded');
         } else {
             if (strtolower($file->extension()) == 'html' or $file->mime() == 'text/html') {
                 throw new Exception('HTML files cannot be uploaded');
             } else {
                 if (strtolower($file->extension()) == 'exe' or $file->mime() == 'application/x-msdownload') {
                     throw new Exception('EXE files cannot be uploaded');
                 } else {
                     if (strtolower($file->filename()) == '.htaccess') {
                         throw new Exception('htaccess files cannot be uploaded');
                     } else {
                         if (str::startsWith($file->filename(), '.')) {
                             throw new Exception('Invisible files cannot be uploaded');
                             // Files blueprint option 'type'
                         } else {
                             if (count($blueprint->files()->type()) > 0 and !in_array($file->type(), $blueprint->files()->type())) {
                                 throw new Exception('Page only allows: ' . implode(', ', $blueprint->files()->type()));
                                 // Files blueprint option 'size'
                             } else {
                                 if ($blueprint->files()->size() and f::size($file->root()) > $blueprint->files()->size()) {
                                     throw new Exception('Page only allows file size of ' . f::niceSize($blueprint->files()->size()));
                                     // Files blueprint option 'width'
                                 } else {
                                     if ($file->type() == 'image' and $blueprint->files()->width() and $file->width() > $blueprint->files()->width()) {
                                         throw new Exception('Page only allows image width of ' . $blueprint->files()->width() . 'px');
                                         // Files blueprint option 'height'
                                     } else {
                                         if ($file->type() == 'image' and $blueprint->files()->height() and $file->height() > $blueprint->files()->height()) {
                                             throw new Exception('Page only allows image height of ' . $blueprint->files()->height() . 'px');
                                         }
                                     }
                                 }
                             }
                         }
                     }
                 }
             }
         }
     }
 }
开发者ID:LucasFyl,项目名称:korakia,代码行数:46,代码来源:files.php

示例9: filterBy

 function filterBy()
 {
     $args = func_get_args();
     $field = a::get($args, 0);
     $operator = '==';
     $value = a::get($args, 1);
     $split = a::get($args, 2);
     if ($value === '!=' || $value === '==' || $value === '*=') {
         $operator = $value;
         $value = a::get($args, 2);
         $split = a::get($args, 3);
     }
     $files = array();
     switch ($operator) {
         // ignore matching elements
         case '!=':
             foreach ($this->_ as $key => $file) {
                 if ($split) {
                     $values = str::split((string) $file->{$field}(), $split);
                     if (!in_array($value, $values)) {
                         $files[$key] = $file;
                     }
                 } else {
                     if ($file->{$field}() != $value) {
                         $files[$key] = $file;
                     }
                 }
             }
             break;
             // search
         // search
         case '*=':
             foreach ($this->_ as $key => $file) {
                 if ($split) {
                     $values = str::split((string) $file->{$field}(), $split);
                     foreach ($values as $val) {
                         if (str::contains($val, $value)) {
                             $files[$key] = $file;
                             break;
                         }
                     }
                 } else {
                     if (str::contains($file->{$field}(), $value)) {
                         $files[$key] = $file;
                     }
                 }
             }
             // take all matching elements
         // take all matching elements
         default:
             foreach ($this->_ as $key => $file) {
                 if ($split) {
                     $values = str::split((string) $file->{$field}(), $split);
                     if (in_array($value, $values)) {
                         $files[$key] = $file;
                     }
                 } else {
                     if ($file->{$field}() == $value) {
                         $files[$key] = $file;
                     }
                 }
             }
             break;
     }
     return new files($files);
 }
开发者ID:codecuts,项目名称:lanningsmith-website,代码行数:66,代码来源:files.php

示例10: checkUpload

 public function checkUpload($file)
 {
     $filesettings = $this->blueprint->files();
     $forbiddenExtensions = array('php', 'html', 'htm', 'exe', kirby()->option('content.file.extension', 'txt'));
     $forbiddenMimes = array_merge(f::$mimes['php'], array('text/html', 'application/x-msdownload'));
     $extension = strtolower($file->extension());
     // files without extension are not allowed
     if (empty($extension)) {
         throw new Exception(l('files.add.error.extension.missing'));
     }
     // block forbidden extensions
     if (in_array($extension, $forbiddenExtensions)) {
         throw new Exception(l('files.add.error.extension.forbidden'));
     }
     // especially block any connection that contains php
     if (str::contains($extension, 'php')) {
         throw new Exception(l('files.add.error.extension.forbidden'));
     }
     // block forbidden mimes
     if (in_array(strtolower($file->mime()), $forbiddenMimes)) {
         throw new Exception(l('files.add.error.mime.forbidden'));
     }
     // Block htaccess files
     if (strtolower($file->filename()) == '.htaccess') {
         throw new Exception(l('files.add.error.htaccess'));
     }
     // Block invisible files
     if (str::startsWith($file->filename(), '.')) {
         throw new Exception(l('files.add.error.invisible'));
     }
     // Files blueprint option 'type'
     if (count($filesettings->type()) > 0 and !in_array($file->type(), $filesettings->type())) {
         throw new Exception(l('files.add.blueprint.type.error') . implode(', ', $filesettings->type()));
     }
     // Files blueprint option 'size'
     if ($filesettings->size() and f::size($file->root()) > $filesettings->size()) {
         throw new Exception(l('files.add.blueprint.size.error') . f::niceSize($filesettings->size()));
     }
     // Files blueprint option 'width'
     if ($file->type() == 'image' and $filesettings->width() and $file->width() > $filesettings->width()) {
         throw new Exception('Page only allows image width of ' . $filesettings->width() . 'px');
     }
     // Files blueprint option 'height'
     if ($file->type() == 'image' and $filesettings->height() and $file->height() > $filesettings->height()) {
         throw new Exception('Page only allows image height of ' . $filesettings->height() . 'px');
     }
 }
开发者ID:robinandersen,项目名称:robin,代码行数:47,代码来源:uploader.php

示例11: parseName

 static function parseName($name)
 {
     if (str::contains($name, '-')) {
         $match = str::match($name, '!^([0-9]+[\\-]+)!', 0);
         $uid = str_replace($match, '', $name);
         $num = trim(rtrim($match, '-'));
     } else {
         $num = false;
         $uid = $name;
     }
     return array('uid' => $uid, 'num' => $num);
 }
开发者ID:narrenfrei,项目名称:kirbycms,代码行数:12,代码来源:pages.php

示例12: foreach

	<div class="social col-xs-6 col-sm-2">
       <iframe class="pull-right" src="//www.facebook.com/plugins/like.php?href=<?php 
echo $page->url();
?>
&amp;send=false&amp;layout=button_count&amp;width=450&amp;show_faces=false&amp;action=like&amp;colorscheme=light&amp;font&amp;height=21&amp;appId=110196125731861" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:450px; height:21px;" allowTransparency="true"></iframe>
	</div>
</div>

<div class="row">
	<?php 
if ($page->images()->count() > 1) {
    ?>
		<div class="gallery">
			<?php 
    $images = $page->images()->filter(function ($image) {
        return !str::contains($image->filename(), 'sponsor') && !str::contains($image->filename(), 'thumbnail');
    });
    foreach ($images as $slide) {
        ?>
				<figure class="gallery-cell col-xs-12">
					<img src="<?php 
        echo $slide->url();
        ?>
">
				</figure>
			<?php 
    }
    ?>
			<div class="gallery-cell col-xs-12">
				<div class="lead col-sm-8 col-sm-offset-2 col-md-6 col-md-offset-3">
					<?php 
开发者ID:caseyg,项目名称:recessnewyork,代码行数:31,代码来源:event.php

示例13: use_cdata

 /**
  * Determine whether or not to wrap a string in CDATA
  *
  * @param	string	string to check
  * @return	bool
  */
 public static function use_cdata($value)
 {
     if (is_numeric($value)) {
         return NO;
     }
     if (!str::contains($value, array("\n", "\r"))) {
         if (strlen(preg_replace("/[a-z0-9\\.\\_ ]+/i", "", $value)) == 0) {
             return NO;
         }
     }
     // We'll make this more extensive later on
     return YES;
 }
开发者ID:enormego,项目名称:EightPHP,代码行数:19,代码来源:xml.php

示例14: hasQuery

 /**
  * Checks if the url contains a query string
  */
 public static function hasQuery($url = null)
 {
     if (is_null($url)) {
         $url = static::current();
     }
     return str::contains($url, '?');
 }
开发者ID:LucasFyl,项目名称:korakia,代码行数:10,代码来源:url.php

示例15: kirby

<?php

if (c::get('cdn.content')) {
    kirby()->urls()->content = c::get('cdn.content');
}
if (c::get('cdn.thumbs')) {
    thumb::$defaults['url'] = c::get('cdn.thumbs');
}
if (c::get('cdn.assets')) {
    $original = url::$to;
    url::$to = function () use($original) {
        $url = call($original, func_get_args());
        if (!str::startsWith($url, kirby()->urls()->index())) {
            return $url;
        }
        if (str::contains($url, '/panel/assets')) {
            return $url;
        }
        $url = preg_replace_callback('!.*?\\/assets\\/(.*)$!', function ($match) {
            return c::get('cdn.assets') . '/' . $match[1];
        }, $url);
        return $url;
    };
}
开发者ID:cfreitag,项目名称:plugins,代码行数:24,代码来源:cdn.php


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