本文整理匯總了PHP中SubStr函數的典型用法代碼示例。如果您正苦於以下問題:PHP SubStr函數的具體用法?PHP SubStr怎麽用?PHP SubStr使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了SubStr函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: Crypt_Decode
function Crypt_Decode($String, $Key = HOST_ID)
{
/****************************************************************************/
$__args_types = array('string', 'string');
#-----------------------------------------------------------------------------
$__args__ = Func_Get_Args();
eval(FUNCTION_INIT);
/****************************************************************************/
$String = Base64_Decode($String);
#-----------------------------------------------------------------------------
if (empty($String)) {
return $String;
}
#-----------------------------------------------------------------------------
if (Extension_Loaded('mcrypt')) {
#---------------------------------------------------------------------------
$Module =& Link_Get('Crypt');
#---------------------------------------------------------------------------
if (!Is_Resource($Module)) {
#-------------------------------------------------------------------------
$Module = @MCrypt_Module_Open(MCRYPT_DES, '', MCRYPT_MODE_ECB, '');
if (!Is_Resource($Module)) {
return ERROR | @Trigger_Error('[Crypt_Decode]: не удалось открыть дескриптор');
}
#-------------------------------------------------------------------------
$Iv = @MCrypt_Create_Iv(MCrypt_Enc_Get_Iv_Size($Module), MCRYPT_RAND);
if (!$Iv) {
return ERROR | @Trigger_Error('[Crypt_Decode]: не удалось создать IV');
}
#-------------------------------------------------------------------------
$Key = SubStr($Key, 0, MCrypt_Enc_Get_Key_Size($Module));
#Debug(SPrintF("[system/libs/auto/Crypt]: Decode Key = %s",$Key));
#-------------------------------------------------------------------------
$IsInit = @MCrypt_Generic_Init($Module, $Key, $Iv);
if (!Is_Integer($IsInit)) {
return ERROR | @Trigger_Error('[Crypt_Decode]: не удалось инициализовать модуль дешифрования');
}
}
#---------------------------------------------------------------------------
$String = @MDecrypt_Generic($Module, $String);
if (!Is_String($String)) {
return ERROR | @Trigger_Error('[Crypt_Decode]: не удалось дешифровать данные');
}
#---------------------------------------------------------------------------
$String = Trim($String);
#---------------------------------------------------------------------------
}
#-----------------------------------------------------------------------------
return $String;
}
示例2: PrepareVariables
public static function PrepareVariables(&$arData)
{
unset($arData["NEW_COMPONENT_TEMPLATE"]);
if ($arData["SEF_MODE"] == "Y") {
unset($arData["VARIABLE_ALIASES"]);
unset($arData["SEF_URL_TEMPLATES"]);
foreach ($arData as $dataKey => $dataValue) {
if (SubStr($dataKey, 0, strlen("SEF_URL_TEMPLATES_")) == "SEF_URL_TEMPLATES_") {
$arData["SEF_URL_TEMPLATES"][SubStr($dataKey, strlen("SEF_URL_TEMPLATES_"))] = $dataValue;
unset($arData[$dataKey]);
if (preg_match_all("'(\\?|&)(.+?)=#([^#]+?)#'is", $dataValue, $arMatches, PREG_SET_ORDER)) {
foreach ($arMatches as $arMatch) {
$arData["VARIABLE_ALIASES"][SubStr($dataKey, strlen("SEF_URL_TEMPLATES_"))][$arMatch[3]] = $arMatch[2];
}
}
} elseif (SubStr($dataKey, 0, strlen("VARIABLE_ALIASES_")) == "VARIABLE_ALIASES_") {
unset($arData[$dataKey]);
}
}
} else {
unset($arData["VARIABLE_ALIASES"]);
unset($arData["SEF_URL_TEMPLATES"]);
foreach ($arData as $dataKey => $dataValue) {
if (SubStr($dataKey, 0, strlen("SEF_URL_TEMPLATES_")) == "SEF_URL_TEMPLATES_") {
unset($arData[$dataKey]);
} elseif (SubStr($dataKey, 0, strlen("VARIABLE_ALIASES_")) == "VARIABLE_ALIASES_") {
$arData["VARIABLE_ALIASES"][SubStr($dataKey, strlen("VARIABLE_ALIASES_"))] = $dataValue;
unset($arData[$dataKey]);
}
}
}
}
示例3: store
public function store(Request $request)
{
$this->validate($request, ['NMbl' => 'required', 'NHbl' => 'required']);
$registrosmars = DB::table('mbls')->where('Nmbl', '=', $request->NMbl)->get();
foreach ($registrosmars as $key) {
}
$pod = $key->POD;
$data = $key->ETA;
$ano = SubStr($data, 0, 4);
$referencia = $key->registro;
$id = $key->id;
$os = 'OS' . $pod . $id . '/' . $ano;
$cnee = $key->cnee;
$mbl = $key->NMbl;
$agenteId = DB::table('agentes')->where('nome', '=', $key->cnee)->get();
foreach ($agenteId as $item) {
}
$valor = $item->valordesconsolmaritimo;
Hbl::create(['ETA' => $data, 'NMbl' => $mbl, 'NHbl' => $request->NHbl, 'referencia' => $os, 'mbl_id' => $id, 'shipper' => $request->shipper, 'cnee' => $request->cnee, 'agente' => $cnee, 'vlrDesconsol' => $valor]);
$hbl = DB::table('hbls')->where('NHbl', '=', $request->NHbl)->get();
foreach ($hbl as $item) {
}
$hblid = $item->id;
Faturamento::create(['documento' => $request->NHbl, 'data' => $data, 'hbl_id' => $hblid, 'referencia' => $referencia, 'OS' => $os]);
return redirect('mbl');
}
示例4: Read
/**
* @param int $Length
* @throws AuthenticationException
*/
public function Read($Length = 1400)
{
// GoldSource RCON has same structure as Query
$this->Socket->Read();
if ($this->Buffer->GetByte() !== SourceQuery::S2A_RCON) {
return false;
}
$Buffer = $this->Buffer->Get();
$Trimmed = Trim($Buffer);
if ($Trimmed === 'Bad rcon_password.') {
throw new AuthenticationException($Trimmed, AuthenticationException::BAD_PASSWORD);
} else {
if ($Trimmed === 'You have been banned from this server.') {
throw new AuthenticationException($Trimmed, AuthenticationException::BANNED);
}
}
$ReadMore = false;
// There is no indentifier of the end, so we just need to continue reading
// TODO: Needs to be looked again, it causes timeouts
do {
$this->Socket->Read();
$ReadMore = $this->Buffer->Remaining() > 0 && $this->Buffer->GetByte() === SourceQuery::S2A_RCON;
if ($ReadMore) {
$Packet = $this->Buffer->Get();
$Buffer .= SubStr($Packet, 0, -2);
// Let's assume if this packet is not long enough, there are no more after this one
$ReadMore = StrLen($Packet) > 1000;
// use 1300?
}
} while ($ReadMore);
$this->Buffer->Set(Trim($Buffer));
}
示例5: QueryMinecraft
function QueryMinecraft($IP, $Port = 25565, $Timeout = 2)
{
$Socket = Socket_Create(AF_INET, SOCK_STREAM, SOL_TCP);
Socket_Set_Option($Socket, SOL_SOCKET, SO_SNDTIMEO, array('sec' => (int) $Timeout, 'usec' => 0));
Socket_Set_Option($Socket, SOL_SOCKET, SO_RCVTIMEO, array('sec' => (int) $Timeout, 'usec' => 0));
if ($Socket === FALSE || @Socket_Connect($Socket, $IP, (int) $Port) === FALSE) {
return FALSE;
}
Socket_Send($Socket, "þ", 2, 0);
$Len = Socket_Recv($Socket, $Data, 512, 0);
Socket_Close($Socket);
if ($Len < 4 || $Data[0] !== "ÿ") {
return FALSE;
}
$Data = SubStr($Data, 3);
// Strip packet header (kick message packet and short length)
$Data = iconv('UTF-16BE', 'UTF-8', $Data);
// Are we dealing with Minecraft 1.4+ server?
if ($Data[1] === "§" && $Data[2] === "1") {
$Data = Explode("", $Data);
return array('HostName' => $Data[3], 'Players' => IntVal($Data[4]), 'MaxPlayers' => IntVal($Data[5]), 'Protocol' => IntVal($Data[1]), 'Version' => $Data[2]);
}
$Data = Explode("§", $Data);
return array('HostName' => SubStr($Data[0], 0, -1), 'Players' => isset($Data[1]) ? IntVal($Data[1]) : 0, 'MaxPlayers' => isset($Data[2]) ? IntVal($Data[2]) : 0, 'Protocol' => 0, 'Version' => '1.3');
}
示例6: loadBaseURL
static function loadBaseURL()
{
$absolute_plugin_folder = RealPath(self::$plugin_folder);
if (StrPos($absolute_plugin_folder, ABSPATH) === 0) {
self::$base_url = Get_Bloginfo('wpurl') . '/' . SubStr($absolute_plugin_folder, Strlen(ABSPATH));
} else {
self::$base_url = Plugins_Url(BaseName(self::$plugin_folder));
}
self::$base_url = Str_Replace("\\", '/', self::$base_url);
# Windows Workaround
}
示例7: FLAP_Explode
function FLAP_Explode($String)
{
/****************************************************************************/
$__args_types = array('string');
#-----------------------------------------------------------------------------
$__args__ = Func_Get_Args();
eval(FUNCTION_INIT);
/****************************************************************************/
if (StrLen($String) < 6) {
return FALSE;
}
#-----------------------------------------------------------------------------
return array('Chanel' => Bytes_Get($String, 01), 'Number' => Bytes_Get($String, 02, 02), 'Data' => SubStr($String, 06));
}
示例8: SNAC_Explode
function SNAC_Explode($String)
{
/****************************************************************************/
$__args_types = array('string');
#-----------------------------------------------------------------------------
$__args__ = Func_Get_Args();
eval(FUNCTION_INIT);
/****************************************************************************/
$Result = array('FamilyID' => Bytes_Get($String, 00, WORD), 'SubTypeID' => Bytes_Get($String, 02, WORD), 'Flag0' => Bytes_Get($String, 05, BUTE), 'Flag1' => Bytes_Get($String, 06, BUTE), 'RequestID' => Bytes_Get($String, 04, BUTE));
#-----------------------------------------------------------------------------
$Result['Data'] = SubStr($String, 11);
# Сам пакет
#-----------------------------------------------------------------------------
return $Result;
}
示例9: Get
/**
* Gets data from buffer
*
* @param int $Length Bytes to read
*
* @return string
*/
public function Get($Length = -1)
{
if ($Length === 0) {
return '';
}
$Remaining = $this->Remaining();
if ($Length === -1) {
$Length = $Remaining;
} else {
if ($Length > $Remaining) {
return '';
}
}
$Data = SubStr($this->Buffer, $this->Position, $Length);
$this->Position += $Length;
return $Data;
}
示例10: __construct
function __construct()
{
// Read base
$this->base_url = get_bloginfo('wpurl') . '/' . Str_Replace("\\", '/', SubStr(RealPath(DirName(__FILE__)), Strlen(ABSPATH)));
// Get ready to translate
$this->Load_TextDomain();
// Set Hooks
if (Is_Admin()) {
Add_Action('admin_menu', array($this, 'add_options_page'));
Add_Action('admin_head', array($this, 'print_admin_header'));
} else {
Add_Action('wp_head', array($this, 'print_header'));
Add_ShortCode('gallery', array($this, 'gallery_shortcode'));
}
// Add jQuery
wp_enqueue_script('jquery');
}
示例11: QueryMinecraft
function QueryMinecraft($IP, $Port = 25565, $Timeout = 2)
{
$Socket = Socket_Create(AF_INET, SOCK_STREAM, SOL_TCP);
Socket_Set_Option($Socket, SOL_SOCKET, SO_SNDTIMEO, array('sec' => (int) $Timeout, 'usec' => 0));
if ($Socket === FALSE || @Socket_Connect($Socket, $IP, (int) $Port) === FALSE) {
return FALSE;
}
Socket_Send($Socket, "þ", 1, 0);
$Len = Socket_Recv($Socket, $Data, 256, 0);
Socket_Close($Socket);
if ($Len < 4 || $Data[0] != "ÿ") {
return FALSE;
}
$Data = SubStr($Data, 3);
$Data = iconv('UTF-16BE', 'UTF-8', $Data);
$Data = Explode("§", $Data);
return array('HostName' => SubStr($Data[0], 0, -1), 'Players' => isset($Data[1]) ? IntVal($Data[1]) : 0, 'MaxPlayers' => isset($Data[2]) ? IntVal($Data[2]) : 0);
}
示例12: TVL_Explode
function TVL_Explode($String, &$Array = array())
{
/****************************************************************************/
$__args_types = array('string', 'array');
#-----------------------------------------------------------------------------
$__args__ = Func_Get_Args();
eval(FUNCTION_INIT);
/****************************************************************************/
$Length = HexDec(Bytes_Get($String, 02, WORD));
#-----------------------------------------------------------------------------
$Array[Bytes_Get($String, 00, WORD)] = SubStr($String, 04, $Length);
#-----------------------------------------------------------------------------
if (StrLen($String = SubStr($String, 04 + $Length)) > 0) {
TVL_Explode($String, $Array);
}
#-----------------------------------------------------------------------------
return $Array;
}
示例13: IO_Files
}
#-------------------------------------------------------------------------------
#-------------------------------------------------------------------------------
$Files = IO_Files(SPrintF('%s/core', SYSTEM_PATH));
if (Is_Error($Files)) {
return SPrintF("---\n%s\n---\n", Implode("\n", Array_Slice($__SYSLOG, Count($__SYSLOG) - 20)));
}
#-------------------------------------------------------------------------------
foreach ($Files as $File) {
#-------------------------------------------------------------------------------
$MD5 = MD5_File($File);
if (!$MD5) {
return SPrintF("---\n%s\n---\n", Implode("\n", Array_Slice($__SYSLOG, Count($__SYSLOG) - 20)));
}
#-------------------------------------------------------------------------------
$File = SubStr($File, StrLen(SYSTEM_PATH) + 1);
#-------------------------------------------------------------------------------
$Snapshot[SPrintF('MD5%s', MD5(SPrintF('%s-%s', $MD5, MD5($File))))] = $File;
#-------------------------------------------------------------------------------
}
#-------------------------------------------------------------------------------
#-------------------------------------------------------------------------------
echo "Запрос обновлений\n";
#-------------------------------------------------------------------------------
$Config = Config();
#-------------------------------------------------------------------------------
$Server = $Config['Update']['Server'];
#-------------------------------------------------------------------------------
$Answer = HTTP_Send('/GetUpdate', $Server, array('HostsIDs' => Implode(',', $HostsIDs)), array('Snapshot' => JSON_Encode($Snapshot)));
if (Is_Error($Answer)) {
return "ERROR: не удалось выполнить запрос к серверу\n";
示例14: Time
<?php
// starting timer for benchmarking purposes
$timer_start = Time() + SubStr(MicroTime(), 0, 8);
session_start();
// main config file with constants
require_once '../config/config.inc';
// error messges
require_once INCLUDE_DIR . 'error.inc';
// create a global PDO object $db
require_once INCLUDE_DIR . 'database.inc';
// database specific code ( all the SQL/whatever queries )
require_once BACKEND_DIR . '/' . DB_TYPE . '/backend.inc';
// set default node id if not specified
if (!empty($_GET['node_id'])) {
$node_id = $_GET['node_id'];
if (!is_numeric($node_id)) {
$node_id = DEFAULT_NODE_ID;
}
} else {
$node_id = DEFAULT_NODE_ID;
}
if (!empty($_GET['template_id'])) {
$template_id = $_GET['template_id'];
if (!is_numeric($template_id)) {
$template_id = false;
}
} else {
// get template_id from node settings later
$template_id = false;
}
示例15: ShowTab
function ShowTab($divName)
{
if (!$this->bInited)
return False;
foreach ($this->arEngines as $key => $value)
{
if (SubStr($divName, 0, StrLen($key."_")) == $key."_")
{
if (array_key_exists("ShowTab", $value))
call_user_func_array($value["ShowTab"], array(SubStr($divName, StrLen($key."_")), $this->arArgs, $this->bVarsFromForm));
}
}
return null;
}