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


PHP Str::substring方法代码示例

本文整理汇总了PHP中Str::substring方法的典型用法代码示例。如果您正苦于以下问题:PHP Str::substring方法的具体用法?PHP Str::substring怎么用?PHP Str::substring使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Str的用法示例。


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

示例1: __call

 /**
  * Sets and returns the expression.
  *
  * @param string	Method that has been called
  * @param array		Given parameters
  *
  * @return string	Expression
  */
 public function __call($func, $args = array())
 {
     if (Str::substring($func, 0, 3) == "set" && isset($args[0])) {
         $this->value = (string) $args[0];
     }
     return $this->value;
 }
开发者ID:enriquesomolinos,项目名称:Bengine,代码行数:15,代码来源:Expr.php

示例2: setDestination

 /**
  * Sets the destination folder.
  *
  * @param string $destination
  * @throws Recipe_Exception_Generic
  * @return Recipe_Language_Exporter
  */
 public function setDestination($destination)
 {
     if (!is_dir($destination) || !is_writable($destination)) {
         throw new Recipe_Exception_Generic("Export destination folder does not exist or is not writable.");
     }
     if (Str::substring($destination, 0, Str::length($destination) - 1) != "/") {
         $destination .= "/";
     }
     $this->destination = $destination;
     return $this;
 }
开发者ID:enriquesomolinos,项目名称:Bengine,代码行数:18,代码来源:Exporter.php

示例3: _execute

 /**
  * Executes all events that are queued, but max 1000 events.
  *
  * @return Bengine_Game_Cronjob_EventExecution
  */
 protected function _execute()
 {
     require_once "Bengine/Game.php";
     $raceConditionKey = Str::substring(md5(microtime(true)), 0, 16);
     /* @var Bengine_Game_Model_Collection_Event $collection */
     $collection = Application::getModel("game/event")->getCollection();
     $collection->addRaceConditionFilter($raceConditionKey, Core::getConfig()->get("CRONJOB_MAX_EVENT_EXECUTION"));
     $collection->executeAll();
     if ($collection->count() > 0) {
         Core::getQuery()->delete("events", "prev_rc = ?", null, null, array($raceConditionKey));
     }
     return $this;
 }
开发者ID:enriquesomolinos,项目名称:Bengine,代码行数:18,代码来源:EventExecution.php

示例4: getTimeTerm

/**
 * Generates a time term of given seconds.
 *
 * @param integer $secs	Seconds
 *
 * @return string	Time term
 */
function getTimeTerm($secs)
{
    $secs = abs($secs);
    Hook::event("FormatTimeStart", array(&$secs));
    $days = floor($secs / 60 / 60 / 24);
    $hours = floor($secs / 60 / 60 % 24);
    $mins = floor($secs / 60 % 60);
    $seconds = floor($secs % 60);
    Hook::event("FormatTimeEnd", array(&$days, &$days, &$mins, &$seconds));
    $parsed = sprintf("%dd %02d:%02d:%02d", $days, $hours, $mins, $seconds);
    if ($days == 0) {
        $parsed = Str::substring($parsed, 3);
    }
    return $parsed;
}
开发者ID:enriquesomolinos,项目名称:Bengine,代码行数:22,代码来源:Functions.inc.php

示例5: __call

 /**
  * Displays the ads.
  *
  * @param string $event	Event mehtod that has been called
  * @param mixed $args	Arguments [ignored]
  *
  * @return Plugin_Commercials
  */
 public function __call($event, $args = null)
 {
     if (Core::getConfig()->get("COMMERCIALS_ENABLED") && !Core::getUser()->ifPermissions("HIDE_ADS")) {
         $this->loadAds();
         $event = Str::substring($event, 2);
         if (isset($this->ads[$event])) {
             $index = array_rand($this->ads[$event]);
             $ad = $this->ads[$event][$index];
             if (Core::getConfig()->get("COUNT_AD_VIEWS")) {
                 Core::getQuery()->update("ad", array("views" => $ad["views"] + 1), "ad_id = ?", array($ad["ad_id"]));
             }
             return htmlspecialchars_decode($ad["html_code"]);
         }
     }
     return null;
 }
开发者ID:enriquesomolinos,项目名称:Bengine,代码行数:24,代码来源:Commercials.plugin.php

示例6: substring

 /**
  * Creates a new string that is a substring of this string.
  *
  * @param integer	The beginning index, inclusive
  * @param integer	The ending index, exclusive [optional]
  *
  * @return String
  */
 public function substring($beginIndex, $endIndex = null)
 {
     $this->string = Str::substring($this->string, $beginIndex, $endIndex);
     return $this;
 }
开发者ID:enriquesomolinos,项目名称:Bengine,代码行数:13,代码来源:String.util.php

示例7: normalizeURL

 /**
  * Normalize the URL into readable string for the Rewrite-Engine.
  *
  * @param string $url	URL to normalize
  *
  * @return string	Normalized URL
  */
 public static function normalizeURL($url)
 {
     if (strpos($url, "?") > 0) {
         $url = preg_replace("/\\?(.*?)=/i", "/\$1:", $url);
         // Replace ?arg= with /arg:
         $url = preg_replace("/\\&(.*?)=/i", "/\$1:", $url);
         // Replace &arg= with /arg:
         $url = preg_replace("/\\&(.*?)=/i", "/\$1:", $url);
         // Replace &arg= with /arg:
         // Now remove useless arg names.
         $parsedURL = parse_url($url);
         $path = Str::substring(Str::replace($_SERVER["SCRIPT_NAME"], "", $parsedURL["path"]), 1);
         $splitted = explode("/", $path);
         $size = count($splitted);
         for ($i = 0; $i < $size; $i++) {
             if (strpos($splitted[$i], ":")) {
                 $splitted[$i] = explode(":", $splitted[$i]);
                 $levelNames = explode(",", REQUEST_LEVEL_NAMES);
                 if (Str::compare($splitted[$i][0], $levelNames[$i], true)) {
                     $url = Str::replace($splitted[$i][0] . ":", "", $url);
                 }
             }
         }
     }
     return BASE_URL . $url;
 }
开发者ID:enriquesomolinos,项目名称:Bengine,代码行数:33,代码来源:Link.util.php

示例8: startSession

 /**
  * Start a new session and destroy old sessions.
  *
  * @return Login
  */
 public function startSession()
 {
     if (!$this->dataChecked) {
         $this->checkData();
     }
     // Disables old sessions.
     if ($this->cacheActive) {
         Core::getCache()->cleanUserCache($this->userid);
     }
     Core::getQuery()->update("sessions", array("logged" => 0), "userid = ?", array($this->userid));
     // Start new session.
     $sessionSeed = Str::encode((string) microtime(1));
     $this->sid = Str::substring($sessionSeed, 0, $this->getSessionLength());
     unset($sessionSeed);
     $spec = array("sessionid" => $this->sid, "userid" => $this->userid, "ipaddress" => IPADDRESS, "useragent" => isset($_SERVER["HTTP_USER_AGENT"]) ? $_SERVER["HTTP_USER_AGENT"] : "", "time" => TIME, "logged" => 1);
     Core::getQuery()->insert("sessions", $spec);
     if ($this->canLogin) {
         if (COOKIE_SESSION) {
             Core::getRequest()->setCookie("sid", $this->sid, $this->getCookieExpire());
             $this->sessionUrl = $this->redirection;
         } else {
             if (Str::inString("?", $this->redirection)) {
                 $this->sessionUrl = $this->redirection . "&sid=" . $this->sid . "&login=true";
             } else {
                 $this->sessionUrl = $this->redirection . "?sid=" . $this->sid . "&login=true";
             }
         }
         if ($this->cacheActive) {
             Core::getCache()->buildUserCache($this->sid);
         }
         Hook::event("StartSession", array($this, $this->sessionUrl));
         if ($this->redirectOnSuccess) {
             doHeaderRedirection($this->sessionUrl, true);
         }
     } else {
         $this->loginFailed("CANNOT_LOGIN");
     }
     return $this;
 }
开发者ID:enriquesomolinos,项目名称:Bengine,代码行数:44,代码来源:Login.util.php

示例9: replaceMember

 /**
  * Generates a list of alliance member.
  *
  * @param string $showPoints	Show points of members
  * @param string $order			List order
  *
  * @return string	Formatted list
  */
 protected function replaceMember($showPoints, $order)
 {
     $this->loadMember($order);
     $showPoints = $this->term($showPoints);
     $out = "";
     foreach ($this->member as $member) {
         $out .= $member["username"];
         if ($showPoints) {
             $out .= " - " . fNumber($member["points"]);
         }
         $out .= "<br/>";
     }
     $out = Str::substring($out, 0, -5);
     return $out;
 }
开发者ID:enriquesomolinos,项目名称:Bengine,代码行数:23,代码来源:Parser.php

示例10: getFileExtension

 /**
  * Fetch the extension of a file name.
  *
  * @param string $filename	The file name.
  * @return string 	The file extension.
  */
 public static function getFileExtension($filename)
 {
     return strtolower(Str::substring(strrchr($filename, "."), 1));
 }
开发者ID:enriquesomolinos,项目名称:Bengine,代码行数:10,代码来源:File.util.php

示例11: getPHPMaxUploadSize

 /**
  * Convert a shorthand byte value from a PHP configuration directive to an integer value.
  *
  * @return integer	Byte value
  */
 protected function getPHPMaxUploadSize()
 {
     $ini_get = ini_get("upload_max_filesize");
     if (is_numeric($ini_get)) {
         return $ini_get;
     }
     $value_length = strlen($ini_get);
     $qty = (int) Str::substring($ini_get, 0, $value_length - 1);
     $unit = strtolower(Str::substring($ini_get, $value_length - 1));
     switch ($unit) {
         case "k":
             $qty *= 1024;
             break;
         case "m":
             $qty *= 1048576;
             break;
         case "g":
             $qty *= 1073741824;
             break;
     }
     return $qty;
 }
开发者ID:enriquesomolinos,项目名称:Bengine,代码行数:27,代码来源:Upload.util.php

示例12: setTemplatePackage

 /**
  * Sets the template package.
  *
  * @param string $package	Package directory
  *
  * @return Recipe_Template_Adapter_Abstract
  */
 public function setTemplatePackage($package = null)
 {
     if (empty($package)) {
         $package = Core::getConfig()->templatepackage;
     }
     if (Str::substring($package, -1) != "/") {
         $package .= "/";
     }
     $this->templatePackage = $package;
     $this->_setup();
     return $this;
 }
开发者ID:enriquesomolinos,项目名称:Bengine,代码行数:19,代码来源:Abstract.php

示例13: setBackQuotes

 /**
  * Surrounds an array with back quotes.
  *
  * @param array
  *
  * @return array
  */
 protected function setBackQuotes($data)
 {
     if (is_array($data)) {
         foreach ($data as &$value) {
             if (Str::substring($value, 0, 1) != "`") {
                 $value = "`" . $value . "`";
             }
         }
         return $data;
     }
     if (Str::substring($data, 0, 1) == "`") {
         return $data;
     }
     return "`" . $data . "`";
 }
开发者ID:enriquesomolinos,项目名称:Bengine,代码行数:22,代码来源:QueryParser.php

示例14: genPrevRaceConditionKey

 /**
  * Generates an unique key to prevend race conditions.
  *
  * @param int $size
  * @return string
  */
 protected function genPrevRaceConditionKey($size = 16)
 {
     $half = floor($size / 2);
     return Str::substring(SID, 0, $half) . Str::substring(md5(microtime(true)), 0, $half);
 }
开发者ID:enriquesomolinos,项目名称:Bengine,代码行数:11,代码来源:EventHandler.php

示例15: splitURL

 /**
  * Split the URL into arguments.
  *
  * @return Recipe_Request
  */
 protected function splitURL()
 {
     $requestedUrl = $this->getRequestedUrl();
     // Remove query string
     if (!empty($_SERVER["QUERY_STRING"])) {
         $requestedUrl = Str::replace("?" . $_SERVER["QUERY_STRING"], "", $requestedUrl);
     }
     $splitted = @parse_url($requestedUrl);
     // Sometimes the first slash causes errors
     if (!$splitted) {
         $splitted = parse_url(Str::substring($requestedUrl, 1));
     }
     // Remove real path from virtual path.
     if (MOD_REWRITE) {
         $path = Str::replace(dirname($_SERVER["SCRIPT_NAME"]) . "/", "", $splitted["path"]);
     } else {
         $path = Str::substring(Str::replace($_SERVER["SCRIPT_NAME"], "", $splitted["path"]), 1);
     }
     if (Str::length($path) > 0) {
         Hook::event("SplitUrlStart", array($this, &$path));
         $path = explode("/", $path);
         foreach ($path as $value) {
             if (strpos($value, ":") > 0) {
                 $value = explode(":", Str::replace(" ", "_", $value));
                 $this->args[] = Arr::trim($value);
             } else {
                 if ($value != "") {
                     $this->args[] = $value;
                 }
             }
         }
         Hook::event("SplitUrlClose", array($this, &$path));
     }
     return $this;
 }
开发者ID:enriquesomolinos,项目名称:Bengine,代码行数:40,代码来源:Request.php


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