本文整理汇总了PHP中strings::strlen方法的典型用法代码示例。如果您正苦于以下问题:PHP strings::strlen方法的具体用法?PHP strings::strlen怎么用?PHP strings::strlen使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类strings
的用法示例。
在下文中一共展示了strings::strlen方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: run
function run()
{
$q = $this->get_param('query');
if (empty($q)) {
$q = functions::request_var('keyword');
}
if (loader::in_ajax()) {
$keyword = trim($q);
} else {
$keyword = trim(urldecode($q));
}
$this->renderer->set_return('keyword', $keyword);
$this->renderer->set_main_title('search');
if (empty($q)) {
return;
}
if (strings::strlen($keyword) < 3) {
$this->renderer->set_message('sat.search_too_short', array('result' => false));
$this->renderer->set_ajax_message('sat.search_too_short');
return false;
}
// make search and redirect to it
$id = $this->make_search($keyword);
// redirect to search results
$url = $this->_controller->get_context()->get_router()->make_url('/search/' . $id . '/');
if (loader::in_ajax()) {
$this->_controller->set_null_template();
$this->renderer->set_ajax_message($this->_found ? sprintf('По вашему запросу найдено %d записей', $this->_found) : 'Подходящих записей не найдено')->set_ajax_result($this->_found)->set_ajax_redirect($url);
} else {
functions::redirect($url);
core::get_instance()->halt();
}
}
示例2: run
function run()
{
$q = trim(urldecode($this->request->get('q')));
$q = core::lib('db')->escape($q);
if (strings::strlen($q) < 2) {
$this->renderer->set_ajax_result(false)->set_ajax_message('Короткое сообщение')->ajax_flush(false);
return;
}
$pmod = $this->_controller->get_context();
$ph = $pmod->get_search_handle()->set_working_fields('keyword')->set_limit(10);
if (!empty($q)) {
$ph->set_where("keyword like '%{$q}%' AND c_count > 0");
}
$sugg = $ph->load()->render();
core::get_instance()->ajax_answer($sugg);
}
示例3: _is_route_matched
/**
* Check route matched to uri
* Extract params (only for regex <?Pname> routes)
*/
private function _is_route_matched($route, &$params)
{
$match = isset($route['match']) ? $route['match'] : false;
$uri = $this->_uri;
// wildcard: /url/blabla/*
if ($match) {
if ($match == '*') {
$match = '';
$uri = '';
} else {
if (strings::strpos($match, '*') !== false) {
$match = strings::substr($match, 0, strings::strpos($match, '*'));
$uri = strings::substr($uri, 0, strings::strlen($match));
}
}
}
return isset($route['regex']) && preg_match($route['regex'], $this->_uri, $params) && array_shift($params) || $match !== false && $uri == $match;
}