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


PHP str_starts_with函数代码示例

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


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

示例1: findNotInstalled

 /**
  * Return array of names of modules that are avilable, but not yet installed
  *
  * @param void
  * @return array
  */
 function findNotInstalled()
 {
     $names = Modules::findNames();
     // names of installed modules
     $modules_path = APPLICATION_PATH . '/modules';
     $d = dir($modules_path);
     if ($d) {
         $result = array();
         while (($entry = $d->read()) !== false) {
             if (str_starts_with($entry, '.') || !is_dir(APPLICATION_PATH . '/modules/' . $entry)) {
                 continue;
             }
             // if
             if (!in_array($entry, $names)) {
                 $module_class = Inflector::camelize($entry) . 'Module';
                 require_once "{$modules_path}/{$entry}/{$module_class}.class.php";
                 $result[] = new $module_class();
             }
             // if
         }
         // while
         return $result;
     }
     // if
     return null;
 }
开发者ID:NaszvadiG,项目名称:activecollab_loc,代码行数:32,代码来源:Modules.class.php

示例2: 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 'null':
         case '(null)':
             return null;
         case 'empty':
         case '(empty)':
             return '';
     }
     if (str_starts_with($value, '"') && str_ends_with($value, '"')) {
         return substr($value, 1, -1);
     }
     return $value;
 }
开发者ID:strongsquirrel,项目名称:yii2-dotenv-app,代码行数:33,代码来源:env.php

示例3: getTranslationFiles

 /**
  * Return array of translation files
  *
  * @param void
  * @return array
  */
 function getTranslationFiles()
 {
     if ($this->translation_files === false) {
         $this->translation_files = array();
         $localization_path = $this->getLocalizationPath();
         $localization_path_len = strlen($localization_path);
         $files = get_files($localization_path, 'php');
         if (is_foreachable($files)) {
             foreach ($files as $path) {
                 $file = substr($path, $localization_path_len + 1);
                 if (!str_starts_with($file, 'module.')) {
                     continue;
                 }
                 // if
                 $this->translation_files[] = substr($file, 7, strlen($file) - 11);
             }
             // foreach
         }
         // if
         if (count($this->translation_files) < 1) {
             $this->translation_files = null;
         }
         // if
     }
     // if
     return $this->translation_files;
 }
开发者ID:NaszvadiG,项目名称:activecollab_loc,代码行数:33,代码来源:Language.class.php

示例4: array_searchRecursive_loose

function array_searchRecursive_loose($needle, $haystack, $strict = false, $path = array(), $exact = false)
{
    global $parent_subtree;
    if (!is_array($haystack)) {
        return false;
    }
    foreach ($haystack as $key => $val) {
        if (is_array($val) && ($subPath = array_searchRecursive_loose($needle, $val, $strict, $path))) {
            $path = array_merge($path, array($key), $subPath);
            return $path;
        } else {
            if (!$strict && str_starts_with($val, $needle) || $strict && str_starts_with($val, $needle)) {
                $path[] = $key;
                $parent_subtree = $haystack;
                return $path;
            } else {
                if (!is_array($val)) {
                    if (preg_match("/" . $needle . "/i", $val, $match)) {
                        $path[] = $key;
                        $parent_subtree = $haystack;
                        return $path;
                    }
                }
            }
        }
    }
    return false;
}
开发者ID:anukat2015,项目名称:ldif,代码行数:28,代码来源:lodd_utils.php

示例5: setPath

 /**
  * @param $path
  */
 public function setPath($path)
 {
     if (!str_starts_with($path, '/')) {
         $path = '/' . $path;
     }
     $this->path = $path;
 }
开发者ID:weew,项目名称:router,代码行数:10,代码来源:Route.php

示例6: add

	/**
	 * Add webpage
	 *
	 * @access public
	 * @param void
	 * @return null
	 */
	function add() {
		if (logged_user()->isGuest()) {
			flash_error(lang('no access permissions'));
			ajx_current("empty");
			return;
		}
		$this->setTemplate('add');
		
		$notAllowedMember = '';
		if(!ProjectWebpage::canAdd(logged_user(), active_context(), $notAllowedMember)) {
			if (str_starts_with($notAllowedMember, '-- req dim --')) flash_error(lang('must choose at least one member of', str_replace_first('-- req dim --', '', $notAllowedMember, $in)));
			else flash_error(lang('no context permissions to add',lang("webpages"), $notAllowedMember));
			ajx_current("empty");
			return;
		} // if

		$webpage = new ProjectWebpage();

		$webpage_data = array_var($_POST, 'webpage');
		
		if(is_array(array_var($_POST, 'webpage'))) {
			try {
				if(substr_utf($webpage_data['url'],0,7) != 'http://' && substr_utf($webpage_data['url'],0,7) != 'file://' && substr_utf($webpage_data['url'],0,8) != 'https://' && substr_utf($webpage_data['url'],0,6) != 'about:' && substr_utf($webpage_data['url'],0,6) != 'ftp://') {
					$webpage_data['url'] = 'http://' . $webpage_data['url'];
				}
				
				$webpage->setFromAttributes($webpage_data);
				
				DB::beginWork();
				$webpage->save();

				$member_ids = json_decode(array_var($_POST, 'members'));
				
				//link it!
                                $object_controller = new ObjectController();
                                $object_controller->add_subscribers($webpage);
                                $object_controller->add_to_members($webpage, $member_ids);
                                $object_controller->link_to_new_object($webpage);
				$object_controller->add_subscribers($webpage);
                                $object_controller->add_custom_properties($webpage);

				ApplicationLogs::createLog($webpage, ApplicationLogs::ACTION_ADD);
				DB::commit();


				flash_success(lang('success add webpage', $webpage->getObjectName()));
				ajx_current("back");
				// Error...
			} catch(Exception $e) {
				DB::rollback();
				flash_error($e->getMessage());
				ajx_current("empty");
			}

		}

		tpl_assign('webpage', $webpage);
		tpl_assign('webpage_data', $webpage_data);
	} // add
开发者ID:Jtgadbois,项目名称:Pedadida,代码行数:66,代码来源:WebpageController.class.php

示例7: search

 /**
  * Execute search
  *
  * @param void
  * @return null
  */
 function search()
 {
     if (active_project() && !logged_user()->isProjectUser(active_project())) {
         flash_error(lang('no access permissions'));
         ajx_current("empty");
         return;
     }
     // if
     $pageType = array_var($_GET, 'page_type');
     $search_for = array_var($_GET, 'search_for');
     $objectManagers = array("ProjectWebpages", "ProjectMessages", "MailContents", "ProjectFiles", "ProjectMilestones", "ProjectTasks", "ProjectEvents");
     $objectTypes = array(lang('webpages'), lang('messages'), lang('emails'), lang('files'), lang('milestones'), lang('tasks'), lang('events'));
     $iconTypes = array('webpage', 'message', 'email', 'file', 'milestone', 'task', 'event');
     if (user_config_option('show_file_revisions_search')) {
         array_splice($objectManagers, 4, 0, 'ProjectFileRevisions');
         array_splice($objectTypes, 4, 0, lang('file contents'));
         array_splice($iconTypes, 4, 0, 'file');
     }
     $search_results = array();
     $timeBegin = microtime(true);
     if (trim($search_for) == '') {
         $search_results = null;
         $pagination = null;
     } else {
         $search_results = $this->searchWorkspaces($search_for, $search_results, 5);
         $search_results = $this->searchUsers($search_for, $search_results, 5);
         $search_results = $this->searchContacts($search_for, $search_results, 5);
         if (array_var($_GET, 'search_all_projects') != "true" && active_project() instanceof Project) {
             $projects = active_project()->getAllSubWorkspacesCSV(true);
         } else {
             $projects = null;
         }
         $c = 0;
         foreach ($objectManagers as $om) {
             $user_id = $om == "MailContents" ? logged_user()->getId() : 0;
             $results = SearchableObjects::searchByType($search_for, $projects, $om, true, 5, 1, null, $user_id);
             if (count($results[0]) > 0) {
                 $sr = array();
                 $sr['result'] = $results[0];
                 $sr['pagination'] = $results[1];
                 $sr['type'] = $objectTypes[$c];
                 $sr['icontype'] = $iconTypes[$c];
                 $sr['manager'] = $om;
                 $search_results[] = $sr;
             }
             $c++;
         }
     }
     // if
     $timeEnd = microtime(true);
     if (str_starts_with($search_for, '"') && str_ends_with($search_for, '"')) {
         $search_for = str_replace('"', '', $search_for);
     }
     tpl_assign('search_string', $search_for);
     tpl_assign('search_results', $search_results);
     tpl_assign('time', $timeEnd - $timeBegin);
     ajx_set_no_toolbar(true);
     ajx_replace(true);
 }
开发者ID:pnagaraju25,项目名称:fengoffice,代码行数:65,代码来源:SearchController.class.php

示例8: update_footer

function update_footer($msg)
{
    global $wp_version;
    if (!str_starts_with($msg, 'Version', false)) {
        return sprintf('Version %s | %s', $wp_version, $msg);
    }
    return $msg;
}
开发者ID:webdeveric,项目名称:wp-starter,代码行数:8,代码来源:admin.php

示例9: login

 /**
  * Log user in
  *
  * @param void
  * @return null
  */
 function login()
 {
     $redirect_to = null;
     // Get page user wanted to visit based on GET params
     if ($this->request->get('re_route')) {
         $params = array();
         foreach ($this->request->url_params as $k => $v) {
             if ($k != 're_route' && str_starts_with($k, 're_')) {
                 $params[substr($k, 3)] = $v;
             }
             // if
         }
         // if
         $redirect_to = assemble_url($this->request->get('re_route'), $params);
     } else {
         $redirect_to = assemble_url('dashboard');
     }
     // if
     // If user is already logged in redirect him to page he wanted to visit
     if (instance_of($this->logged_user, 'User')) {
         flash_error('You are already logged in as :display. Please logout before you can login on another account', array('display' => $this->logged_user->getDisplayName()));
         $this->redirectToUrl($redirect_to);
     }
     // if
     $login_data = $this->request->post('login');
     $this->smarty->assign(array('login_data' => $login_data, 'auto_focus' => true));
     if ($this->request->isSubmitted()) {
         $errors = new ValidationErrors();
         $email = trim(array_var($login_data, 'email'));
         $password = array_var($login_data, 'password');
         $remember = (bool) array_var($login_data, 'remember');
         if ($email == '') {
             $errors->addError(lang('Email address is required'), 'email');
         }
         // if
         if (trim($password) == '') {
             $errors->addError(lang('Password is required'), 'password');
         }
         // if
         if ($errors->hasErrors()) {
             $this->smarty->assign('auto_focus', false);
             $this->smarty->assign('errors', $errors);
             $this->render();
         }
         // if
         $user =& $this->authentication->provider->authenticate(array('email' => $email, 'password' => $password, 'remember' => $remember));
         if (!$user || is_error($user)) {
             $errors->addError(lang('Failed to log you in with data you provided. Please try again'), 'login');
             $this->smarty->assign('errors', $errors);
             $this->render();
         }
         // if
         flash_success(lang('Welcome back :display!', array('display' => $user->getDisplayName()), true, $user->getLanguage()), null, true);
         $this->redirectToUrl($redirect_to);
     }
     // if
 }
开发者ID:NaszvadiG,项目名称:activecollab_loc,代码行数:63,代码来源:AuthController.class.php

示例10: testStrStartsWith

 /**
  * test str_starts_with
  */
 public function testStrStartsWith()
 {
     $this->assertTrue(str_starts_with('foobar', 'foo'));
     $this->assertTrue(str_starts_with('foobar', 'foobar'));
     $this->assertFalse(str_starts_with('foobar', 'qux'));
     $this->assertFalse(str_starts_with('foobar', 'bar'));
     $this->assertFalse(str_starts_with('foobar', 'oba'));
     $this->assertFalse(str_starts_with('foobar', 'foobarqux'));
 }
开发者ID:sachsy,项目名称:php-functions,代码行数:12,代码来源:StringFunctionsTest.php

示例11: _registerHandlers

 function _registerHandlers()
 {
     foreach ($this->mappings as $url => $handler) {
         if (!str_starts_with($url, '/')) {
             $url = '/' . $url;
         }
         $this->registerHandler($url, $handler);
     }
 }
开发者ID:qlixes,项目名称:springphp,代码行数:9,代码来源:SimpleUrlHandlerMapping.php

示例12: __callStatic

 public static function __callStatic($method_name, $args)
 {
     $classname = get_called_class();
     if (method_exists($classname, $method_name)) {
         return call_user_func(array($classname, $method_name));
     } elseif (str_starts_with($method_name, 'find_by_')) {
         $attribute = substr($method_name, 8);
         return static::find_by($attribute, $args[0]);
     }
 }
开发者ID:stephenhandley,项目名称:temovico,代码行数:10,代码来源:MySQLModel.php

示例13: isRoutable

 /**
  * Determine if the given controller method is routable.
  *
  * @param  \ReflectionMethod  $method
  * @return bool
  */
 public function isRoutable(ReflectionMethod $method)
 {
     switch ($method->class) {
         case 'Routing\\Controller':
         case 'App\\Core\\Controller':
             return false;
         default:
             return str_starts_with($method->name, $this->verbs);
     }
     return false;
 }
开发者ID:nova-framework,项目名称:cms,代码行数:17,代码来源:ControllerInspector.php

示例14: smarty_block_link

/**
 * Render button
 * 
 * Parameters:
 * 
 * - common anchor parameter
 * 
 * - method - if POST that this button will be send POST request. Method works 
 *   only if href parameter is present
 * - confirm - enforces confirmation dialog
 *   codes
 *
 * @param array $params
 * @param string $content
 * @param Smarty $smarty
 * @param boolean $repeat
 * @return string
 */
function smarty_block_link($params, $content, &$smarty, &$repeat)
{
    $href = '';
    if (isset($params['href'])) {
        $href = $params['href'];
        if (str_starts_with($href, '?')) {
            $href = assemble_from_string($params['href']);
        }
        // if
    }
    // if
    $params['href'] = $href;
    $confirm = '';
    if (array_key_exists('confirm', $params)) {
        $confirm = lang(trim($params['confirm']));
        unset($params['confirm']);
    }
    // if
    $post = false;
    if (array_key_exists('method', $params)) {
        if (strtolower($params['method']) == 'post') {
            $post = true;
        }
        // if
        unset($params['method']);
    }
    // if
    if ($post || $confirm) {
        $execution = $post ? 'App.postLink(' . var_export($href, true) . ')' : 'location.href = ' . var_export($href, true);
        if ($confirm) {
            $params['onclick'] = "if(confirm(" . var_export($confirm, true) . ")) { {$execution}; } return false;";
        } else {
            $params['onclick'] = "{$execution}; return false;";
        }
        // if
    }
    // if
    $not_lang = false;
    if (isset($params['not_lang'])) {
        $not_lang = (bool) $params['not_lang'];
        unset($params['not_lang']);
    }
    // if
    if (array_key_exists('id', $params) && strlen($params['id']) == 0) {
        unset($params['id']);
    }
    // if
    if (array_key_exists('title', $params)) {
        $params['title'] = lang($params['title']);
    }
    // if
    $text = $not_lang ? $content : lang($content);
    return open_html_tag('a', $params) . $text . '</a>';
}
开发者ID:NaszvadiG,项目名称:activecollab_loc,代码行数:72,代码来源:block.link.php

示例15: url_trimAndClean

function url_trimAndClean($url)
{
    $url = trim($url);
    if (str_starts_with($url, '/')) {
        $url = substr($url, 1);
    }
    if (str_ends_with($url, '/')) {
        $url = substr($url, 0, strlen($url) - 1);
    }
    $url = strtolower($url);
    return $url;
}
开发者ID:GrapheneProject,项目名称:Graphene,代码行数:12,代码来源:utils.php


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