本文整理汇总了PHP中strings::strpos方法的典型用法代码示例。如果您正苦于以下问题:PHP strings::strpos方法的具体用法?PHP strings::strpos怎么用?PHP strings::strpos使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类strings
的用法示例。
在下文中一共展示了strings::strpos方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: smarty_modifier_is_url
/**
* Smarty is_url modifier plugin
*
* Type: modifier<br>
* Name: truncate<br>
* Purpose: Truncate a string to a certain length if necessary,
* optionally splitting in the middle of a word, and
* appending the $etc string or inserting $etc into the middle.
* @link http://smarty.php.net/manual/en/language.modifier.truncate.php
* truncate (Smarty online manual)
* @author Monte Ohrt <monte at ohrt dot com>
* @param string
* @param integer
* @param string
* @param boolean
* @param boolean
* @return string
*/
function smarty_modifier_is_url($url, $origurl = null)
{
if (empty($url)) {
return false;
}
if (!isset($origurl)) {
$origurl = urldecode($_SERVER['REQUEST_URI']);
}
return strings::strpos($origurl, $url) === 0 ? true : false;
}
示例2: login
/**
* Login stuff
*/
function login()
{
if ($this->_authed) {
return;
}
$this->_in_login = true;
core::dprint(array("[MW_LOGIN] %s:%s (%s)", $this->_acc->login, $this->_acc->password, $this->_acc->c_name));
/** @var http */
$http = $this->_http();
$http->set_debug($this->_debug);
$this->_in_login = false;
/** @var sae_cacher */
$sc = core::lib('sape_cacher');
$http->wget(self::MOSWAR_URL);
$this->sleep(5, 5);
/*
var_dump(
$http->post(self::MOSWAR_URL . 'login_mock.php', $this->_acc->as_array())
);
*/
$post_data = array('action' => 'login', 'email' => $this->_acc->login, 'password' => $this->_acc->password, 'remember' => 'on');
//$buffer = $http->post(self::MOCK_URL /*MOSWAR_URL*/, $post_data);
$buffer = $http->post(self::MOSWAR_URL, $post_data);
$http->SaveCookies($cooks);
if ($this->_debug) {
file_put_contents('login-out.html', $buffer);
file_put_contents('login-out-cookie.html', var_export($cooks, 1));
}
if ($cooks && strings::strpos($buffer, 'Неверно указан e-mail адрес или пароль') === false) {
$sc->set('cookie', $this->_acc->id, $cooks);
$this->_authed = true;
} else {
throw new moswar_exception('Cant login: ' . $this->_acc->login);
}
}
示例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;
}