本文整理汇总了PHP中str_contains函数的典型用法代码示例。如果您正苦于以下问题:PHP str_contains函数的具体用法?PHP str_contains怎么用?PHP str_contains使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了str_contains函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: guess
/**
* Guess the HREF for a button.
*
* @param TableBuilder $builder
*/
public function guess(TableBuilder $builder)
{
$buttons = $builder->getButtons();
if (!($section = $this->sections->active())) {
return;
}
if (!($module = $this->modules->active())) {
return;
}
$stream = $builder->getTableStream();
foreach ($buttons as &$button) {
// If we already have an HREF then skip it.
if (isset($button['attributes']['href'])) {
continue;
}
switch (array_get($button, 'button')) {
case 'restore':
$button['attributes']['href'] = $this->url->to('entry/handle/restore/' . $module->getNamespace() . '/' . $stream->getNamespace() . '/' . $stream->getSlug() . '/{entry.id}');
break;
default:
// Determine the HREF based on the button type.
$type = array_get($button, 'segment', array_get($button, 'button'));
if ($type && !str_contains($type, '\\') && !class_exists($type)) {
$button['attributes']['href'] = $section->getHref($type . '/{entry.id}');
}
break;
}
}
$builder->setButtons($buttons);
}
开发者ID:huglester,项目名称:streams-platform,代码行数:35,代码来源:HrefGuesser.php
示例2: api
/**
* Get the API ancestor controller class
* of the current controller class.
*
* @return Esensi\Core\Http\Controllers\ApiController
*/
public function api()
{
// Make a copy of the parent class
$class = get_parent_class();
$parent = App::make($class);
// Copy over the packaged properties
if ($this instanceof PackagedInterface) {
$parent->setUI($this->getUI());
$parent->setPackage($this->getPackage());
$parent->setNamespacing($this->getNamespacing());
}
// Copy over the injected repositories
if ($this instanceof RepositoryInjectedInterface) {
foreach ($this->repositories as $name => $repository) {
$parent->setRepository($repository, $name);
}
}
// Return first ApiController ancestor found
if (str_contains($class, 'ApiController')) {
return $parent;
}
// Recursively look up the parent class
if (method_exists($parent, 'api')) {
return $parent->api();
}
// Return the parent class found already
return $parent;
}
开发者ID:esensi,项目名称:core,代码行数:34,代码来源:ApiAncestryControllerTrait.php
示例3: getPosterAttribute
/**
* Returns default image if title doesnt have poster.
*
* @param string $value
* @return string
*/
public function getPosterAttribute($value)
{
if ($value && !str_contains($value, 'http')) {
return url($value);
}
return $value;
}
开发者ID:onlystar1991,项目名称:mtdb,代码行数:13,代码来源:Episode.php
示例4: getFileName
/**
* Get the downloadable file name for this upload.
* @return mixed|string
*/
public function getFileName()
{
if (str_contains($this->name, '.')) {
return $this->name;
}
return $this->name . '.' . $this->extension;
}
开发者ID:ssddanbrown,项目名称:bookstack,代码行数:11,代码来源:Attachment.php
示例5: retrieveByCredentials
/**
* Retrieve a user by the given credentials.
*
* @param array $credentials
* @return \Illuminate\Auth\UserInterface|null
*/
public function retrieveByCredentials(array $credentials)
{
// First we will add each credential element to the query as a where clause.
// Then we can execute the query and, if we found a user, return it in a
// Eloquent User "model" that will be utilized by the Guard instances.
$query = $this->createModel()->newQuery();
$idKey = $this->config['netidColumn'];
$credientials[$idKey] = strtolower($credentials[$idKey]);
foreach ($credentials as $key => $value) {
if (!str_contains($key, 'password')) {
$query->where($key, $value);
}
}
if ($query->first()) {
return $query->first();
}
if (!$this->autoCreate) {
return null;
}
if ($this->validateLdapCredentials($credentials)) {
$idValue = $credentials[$idKey];
$firstNameKey = $this->firstNameKey;
$lastNameKey = $this->lastNameKey;
$emailKey = $this->emailKey;
$info = $this->retrieveLdapUserInfo($idValue);
$user = $this->createModel();
$user->{$firstNameKey} = $info['first_name'];
$user->{$lastNameKey} = $info['last_name'];
$user->{$idKey} = $idValue;
$user->{$emailKey} = $info['email'];
$user->save();
return $user;
}
return null;
}
开发者ID:azamtav,项目名称:opensso-auth,代码行数:41,代码来源:OpenSSOAuth.php
示例6: create
/**
* Create a new user instance.
*
* @param array $data
*
* @return User
*/
public function create(array $data)
{
unset($data['g-recaptcha-response']);
unset($data['password_confirmation']);
//use Gravatar if a user has one
try {
if (!isset($data['avatar']) && Gravatar::exists($data['email'])) {
$data['avatar'] = Gravatar::get($data['email']);
}
} catch (\ErrorException $e) {
if (App::environment('local', 'testing') && str_contains($e->getMessage(), 'get_headers(): php_network_getaddresses: getaddrinfo failed: nodename nor servname provided')) {
Log::debug('We are probably offline, so this is being suppressed to avoid test failures');
} else {
throw $e;
}
}
$user = App::make(User::class, [$data]);
//third party account creation won't have a password
if (isset($data['password'])) {
$user->password = bcrypt($data['password']);
}
$user->save();
event('auth.registered', [$user]);
return $user;
}
开发者ID:BibleBowl,项目名称:account,代码行数:32,代码来源:Registrar.php
示例7: setReferer
function setReferer($source, $current)
{
$referer = isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : '';
str_contains($referer, $current) && str_contains(session('referer'), $source) ? $referer = session('referer') : ($referer = $referer);
str_contains($referer, $source) ? session(['referer' => $referer]) : session(['referer' => $source]);
return session('referer');
}
开发者ID:koyeo,项目名称:bichon,代码行数:7,代码来源:Helper.php
示例8: index
public function index()
{
$urls = [];
$routes = Route::getRoutes();
foreach ($routes as $route) {
$path = $route->getPath();
$actions = $route->getAction();
$params = $route->parameterNames();
$controller = $actions['controller'];
if (starts_with($path, '_') or str_contains($controller, 'RedirectController') or count($params)) {
continue;
}
$urls[] = url($path);
}
foreach (Campus::all() as $item) {
$urls[] = url($item->url);
}
foreach (Event::all() as $item) {
$urls[] = url($item->url);
}
foreach (Series::withDrafts()->get() as $item) {
$urls[] = url($item->url);
}
foreach (Staff::all() as $item) {
$urls[] = url($item->url);
}
foreach (MissionLocation::all() as $item) {
$urls[] = url($item->url);
}
foreach (Video::withDrafts()->get() as $item) {
$urls[] = url($item->url);
}
return response()->json($urls);
}
开发者ID:mcculley1108,项目名称:faithpromise.org,代码行数:34,代码来源:SiteMapController.php
示例9: fire
public function fire()
{
if (!$this->option('tenant')) {
return parent::fire();
}
if ($this->option('tenant') == 'all') {
$websites = $this->website->all();
} else {
$websites = $this->website->queryBuilder()->whereIn('id', explode(',', $this->option('tenant')))->get();
}
// forces database to tenant
if (!$this->option('database')) {
$this->input->setOption('database', 'tenant');
}
foreach ($websites as $website) {
$this->info("Migrating for {$website->id}: {$website->present()->name}");
$website->database->setCurrent();
$this->repository->setSource($website->database->name);
try {
$this->repository->createRepository();
} catch (PDOException $e) {
if (str_contains($e->getMessage(), ['Base table or view already exists'])) {
$this->info("Migration table already exists: {$e->getMessage()}");
continue;
}
}
$this->info('Migration table created successfully.');
}
}
开发者ID:Mobytes,项目名称:multi-tenant,代码行数:29,代码来源:InstallCommand.php
示例10: handle
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @return mixed
*/
public function handle($request, Closure $next)
{
if (!$request->secure() && !str_contains($request->getRequestUri(), '/podcasts/rss')) {
return redirect()->secure($request->getRequestUri(), 301);
}
return $next($request);
}
开发者ID:WellCoded,项目名称:website,代码行数:14,代码来源:Secure.php
示例11: create
public function create(Request $request)
{
if (str_contains($request->input("bg_image"), "simple")) {
return $this->createsimple($request);
}
return $this->createpolaroid($request);
}
开发者ID:HEERLIJKNL,项目名称:WeRotterdam,代码行数:7,代码来源:ImageCreateController.php
示例12: isHtmlResponse
private function isHtmlResponse($response)
{
if (is_object($response) && $response instanceof Response && str_contains($response->headers->get('Content-Type'), 'text/html')) {
return false;
}
return true;
}
开发者ID:alcodo,项目名称:async-css,代码行数:7,代码来源:AsyncCssMiddleware.php
示例13: Login
/**
* 模拟登录
*/
public function Login($verifycode = NULL)
{
$data = $this->account;
if (!is_numeric($data['username']) && !str_contains($data['username'], '@')) {
return '用户名格式错误,请输入QQ号或QQ邮箱。';
}
Session::Set('qq', $data['username']);
if (!$verifycode) {
$ret = $this->get('http://check.ptlogin2.qq.com/check?appid=15000101&uin=' . $data['username']);
//
$arr = explode("'", $ret);
$verifycode = $arr[3];
if (strlen($verifycode) != 4) {
return '绑定账号失败:请输入验证码';
//'登录服务暂时不可用,请稍后再试!';
}
}
$param = array('aid' => 15000101, 'fp' => 'loginerroralert', 'from_ui' => 1, 'g' => 1, 'h' => 1, 'u' => $data['username'], 'p' => $this->encpwd($data['password'], $data['username'], $verifycode), 'verifycode' => $verifycode, 'u1' => 'http://imgcache.qq.com/qzone/v5/loginsucc.html?para=izone');
Log::customLog('qzone.txt', "GET http://ptlogin2.qq.com/login:\r\n" . print_r($param, true));
$ret = $this->get('http://ptlogin2.qq.com/login?' . http_build_query($param));
Log::customLog('qzone.txt', "Response:\r\n" . print_r($this->http_header, true) . print_r($ret, true));
$arr = explode("'", $ret);
$ret = $arr[9];
if (start_with($ret, '登录成功')) {
return true;
}
return $ret;
}
开发者ID:z445056647,项目名称:phx-svns,代码行数:31,代码来源:QZoneSimulaAPI.class.php
示例14: 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
示例15: loadLaravelRoutes
/**
* Load the Laravel routes into the application routes for
* permission assignment.
*
* @return int The number of Laravel routes loaded.
*/
public static function loadLaravelRoutes()
{
$AppRoutes = \Route::getRoutes();
$cnt = 0;
foreach ($AppRoutes as $appRoute) {
$name = $appRoute->getName();
$methods = $appRoute->getMethods();
$path = $appRoute->getPath();
$actionName = $appRoute->getActionName();
if (!str_contains($actionName, 'AuthController') && !str_contains($actionName, 'PasswordController')) {
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++;
$newRoute = Route::create(['name' => $name, 'method' => $method, 'path' => $path, 'action_name' => $actionName, 'enabled' => 1]);
}
}
}
}
}
return $cnt;
}
开发者ID:bztrn,项目名称:laravel-5.1-enterprise-starter-kit,代码行数:36,代码来源:Route.php
示例16: humanize_title
function humanize_title($filename)
{
$replacement = array('ss' => '', 'bb' => 'B&B Editor', 'mixer' => 'FX Mixer', 'roll' => 'Roll Editor', 'plugins' => 'Native Instruments', 'automation' => 'Automation Editor', 'vst' => 'VSTi Running via Vestige');
$title_split = explode('_', $filename);
$found = false;
foreach ($title_split as &$item) {
// Skip 01, 02, etc
if (is_numeric($item)) {
$item = '';
continue;
}
// Substitute array reference with the text above
if (str_contains($item, '.png', false)) {
$item = str_replace('.png', '', $item);
}
if (array_key_exists($item, $replacement)) {
$temp = $replacement[$item];
$item = ($found ? ', ' : ' ') . $temp;
$found = trim($temp) != '' ? true : false;
} else {
$item = ' ' . ucfirst($item);
}
}
return trim(implode('', $title_split));
}
开发者ID:kmklr72,项目名称:lmms.io,代码行数:25,代码来源:views.php
示例17: shouldPrerender
/**
* Returns whether the request must be prerendered server side for crawler.
*
* @param Request $request
* @return bool
*/
private function shouldPrerender(Request $request)
{
$userAgent = strtolower($request->server->get('HTTP_USER_AGENT'));
$bufferAgent = $request->server->get('X-BUFFERBOT');
$shouldPrerender = false;
if (!$userAgent) {
return false;
}
if (!$request->isMethod('GET')) {
return false;
}
//google bot
if ($request->query->has('_escaped_fragment_')) {
$shouldPrerender = true;
}
//other crawlers
foreach ($this->userAgents as $crawlerUserAgent) {
if (str_contains($userAgent, strtolower($crawlerUserAgent))) {
$shouldPrerender = true;
}
}
if ($bufferAgent) {
$shouldPrerender = true;
}
if (!$shouldPrerender) {
return false;
}
return true;
}
开发者ID:syntropysoftware,项目名称:cryptoffice-frontend,代码行数:35,代码来源:PrerenderIfCrawler.php
示例18: vote
public function vote()
{
$class = \Input::get('class');
$postId = \Input::get('postId');
$previousVote = PostVote::where('user_id', \Auth::id())->where('post_id', $postId)->first();
$isUpvote = str_contains($class, 'up');
// If there is a vote by the same user on the same post
if (!is_null($previousVote)) {
if ($isUpvote) {
if ($previousVote->type === 'up') {
// Cancel out previous upvote
$previousVote->delete();
} else {
$previousVote->update(['type' => 'up']);
}
} else {
if ($previousVote->type === 'down') {
// Cancel out previous downvote
$previousVote->delete();
} else {
$previousVote->update(['type' => 'down']);
}
}
} else {
// Create a new vote
PostVote::create(['type' => $isUpvote ? 'up' : 'down', 'user_id' => \Auth::id(), 'post_id' => $postId]);
}
}
开发者ID:reverserob,项目名称:Laravel,代码行数:28,代码来源:VoteController.php
示例19: getTheme
/**
* Return currently active theme.
*
* @return string
*/
public function getTheme()
{
if (App::environment() === 'demo' && str_contains(url(), 'mercury')) {
return 'mercury';
}
return isset($this->options['theme']) ? $this->options['theme'] : 'original';
}
开发者ID:onlystar1991,项目名称:mtdb,代码行数:12,代码来源:Options.php
示例20: isSigned
/**
* @return bool
* @throws Exception
*/
public function isSigned()
{
if (!$this->isNumeric()) {
throw new Exception('This method should only be called on numeric columns');
}
return !str_contains($this->type, 'unsigned');
}
开发者ID:votemike,项目名称:dbhelper,代码行数:11,代码来源:Column.php
注:本文中的str_contains函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论