本文整理汇总了PHP中Str::sub方法的典型用法代码示例。如果您正苦于以下问题:PHP Str::sub方法的具体用法?PHP Str::sub怎么用?PHP Str::sub使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Str
的用法示例。
在下文中一共展示了Str::sub方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: action_main
public function action_main($params = array())
{
$config = $this->config;
$gConfig = \Config::load('novius_social_widget::config', true);
if (Arr::get($gConfig, 'embed_js', true)) {
if (!empty($config['js'])) {
foreach ($config['js'] as $script) {
Nos::main_controller()->addJavascript($script);
}
}
}
$chrome = array();
$typeList = array('chrome');
foreach ($params as $param => $value) {
if ($value) {
foreach ($typeList as $type) {
$typePrefix = "{$type}-";
if ($value && \Str::starts_with($param, $typePrefix)) {
array_push(${$type}, \Str::sub($param, \Str::length($typePrefix)));
}
}
}
}
return \View::forge('novius_social_widget::front/enhancer/twitter', array('widgetId' => $params['widget-id'], 'chrome' => $chrome, 'limit' => \Arr::get($params, 'limit'), 'width' => \Arr::get($params, 'width'), 'height' => \Arr::get($params, 'height')), false);
}
示例2: foreach
<?php
$curLetter = null;
/** @var \Novius\Glossary\Model_Word[] $items */
foreach ($items as $item) {
$letter = iconv('UTF-8', 'ASCII//TRANSLIT', \Str::lower(\Str::sub($item->title_item(), 0, 1)));
if ($letter != $curLetter) {
if ($curLetter !== null) {
?>
</section>
<?php
}
$curLetter = $letter;
?>
<hgroup>
<?php
echo $letter;
?>
</hgroup>
<section class="block">
<?php
}
echo \View::forge('novius_glossary::front/item', array('item' => $item, 'config' => $config), false);
?>
<?php
}
?>
</section>
示例3: authenticate
/**
* Authenticate to the desired account.
*
* @return boolean True if the authentication was successful, false otherwise.
*/
public static function authenticate()
{
$auth = \Input::headers('X-Authorization');
// If we're trying to run a JS call...
if (empty($auth) && \V1\APIRequest::get('consumer_key', null) !== null) {
// We're making a public call through JS, so we'll mark it as a reduced functionality call.
\Session::set('public', true);
// This session variable aids in logging and API functionality later.
\Session::set('consumer_key', \V1\APIRequest::get('consumer_key'));
$account_data = \V1\Model\Account::get_account();
// If the account is invalid, fail.
if (empty($account_data)) {
return false;
}
/*
* If the account holder wishes to allow for JS based calls, we'll allow safe calls to run
* with their API key by turning on public mode.
*/
if ($account_data['js_calls_allowed'] === 0) {
return false;
}
/**
* @TODO JS calls go through the client's IP, so we can't use a whitelist.
* In the future, perhaps a blacklist deadicated to client IPs is in order?
* If the account holder uses a whitelist, then they've just disabled their
* blacklist of the client IPs. It really should be separated, but for now
* it's unimplemented.
*/
// IP ACL
if ($account_data['acl_type'] === 0 && static::ip_acl_check() === false) {
return false;
}
// We're clear for lift off.
return true;
} elseif (!empty($auth)) {
// Give the call full account access if we succeed in validating the request.
\Session::set('public', false);
// Is it an OAuth authorization header?
if (\Str::sub($auth, 0, 5) !== 'OAuth') {
return false;
}
// Parse the OAuth header into an array
parse_str(\Str::sub($auth, 6, strlen($auth)), $tokens);
$required_keys = array('oauth_signature', 'oauth_nonce', 'oauth_timestamp', 'oauth_consumer_key');
// This session variable aids in logging and API functionality later.
if (empty($tokens['oauth_consumer_key'])) {
return false;
}
\Session::set('consumer_key', $tokens['oauth_consumer_key']);
// IP ACL
if (static::ip_acl_check() === false) {
return false;
}
// Do we have all the correct keys?
if (count(array_intersect_key(array_flip($required_keys), $tokens)) !== count($required_keys)) {
return false;
}
// Verify the data integrity of the header's components, including if the timestamp is new enough.
if (!(isset($tokens['oauth_consumer_key'], $tokens['oauth_signature'], $tokens['oauth_nonce']) && static::valid_timestamp($tokens['oauth_timestamp']) === true)) {
return false;
}
// Do we have a valid nonce?
if (static::valid_nonce($tokens) === false) {
return false;
}
// Verify that the signature matches the content.
if (static::valid_signature($tokens) === false) {
return false;
}
// If we haven't failed yet, then it's valid.
return true;
}
return false;
}
示例4: handle_tags
protected function handle_tags($string)
{
$tag = Str::sub(strtok($string, " \t\n\r\v>"), 1);
if ($tag[0] != '/' && !in_array($tag, $this->options['single_tags'])) {
$this->tags[] = $tag;
} elseif (end($this->tags) == Str::sub($tag, 1)) {
array_pop($this->tags);
}
}
示例5: implode
/**
* @param string $glue
* @param array $array
* @return string
*/
public static function implode($glue, array $array)
{
$result = '';
foreach ($array as $item) {
if (is_array($item)) {
$result .= self::implode($glue, $item) . $glue;
} else {
$result .= $item . $glue;
}
}
if ($glue) {
$result = Str::sub($result, 0, 0 - Str::len($glue));
}
return $result;
}