本文整理汇总了PHP中StrLen函数的典型用法代码示例。如果您正苦于以下问题:PHP StrLen函数的具体用法?PHP StrLen怎么用?PHP StrLen使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了StrLen函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: Query
public function Query()
{
$Length = StrLen($this->ServerIP);
$Data = Pack('cccca*', HexDec($Length), 0, 0x4, $Length, $this->ServerIP) . Pack('nc', $this->ServerPort, 0x1);
Socket_Send($this->Socket, $Data, StrLen($Data), 0);
// handshake
Socket_Send($this->Socket, "", 2, 0);
// status ping
$Length = $this->ReadVarInt();
// full packet length
if ($Length < 10) {
return FALSE;
}
Socket_Read($this->Socket, 1);
// packet type, in server ping it's 0
$Length = $this->ReadVarInt();
// string length
$Data = Socket_Read($this->Socket, $Length, PHP_NORMAL_READ);
// and finally the json string
if ($Data === FALSE) {
throw new MinecraftPingException('Server didn\'t return any data');
}
$Data = JSON_Decode($Data, true);
if (JSON_Last_Error() !== JSON_ERROR_NONE) {
if (Function_Exists('json_last_error_msg')) {
throw new MinecraftPingException(JSON_Last_Error_Msg());
} else {
throw new MinecraftPingException('JSON parsing failed');
}
return FALSE;
}
return $Data;
}
示例2: newai_list_one
function newai_list_one()
{
global $db, $common_html, $tablename_one, $tablename_two, $link;
global $html_etc_one, $html_etc_two, $columns_one, $columns_two;
global $tablename, $SYTEM_CONFIG_TABLE;
global $SUNSHINE_USER_NAME_VAR, $SUNSHINE_USER_ID_VAR, $_SESSION;
$USER_NAME = $_SESSION[$SUNSHINE_USER_NAME_VAR];
print "<SCRIPT language=JavaScript>\n\tfunction clickMenu(url){\n\tparent.main_body.location=url;\n\t}\n\t</SCRIPT>\n\t";
$one_array = explode(':', $tablename_one);
//print_R($one_array);
$link_array = explode(':', $link);
//print_R($link_array);
$columns = returntablecolumn($tablename);
$columns_one = returntablecolumn($one_array[0]);
$html_etc_one = returnsystemlang($one_array[0], $SYTEM_CONFIG_TABLE);
switch ($db->databaseType) {
case 'mysql':
switch ($one_array[3]) {
case 'name':
$sql_one = "select " . $columns_one[(string) $one_array[1]] . "," . $columns_one[(string) $one_array[2]] . " from " . $one_array[0] . " where " . $columns_one[(string) $one_array[4]] . "='" . $USER_NAME . "'";
break;
case 'id':
$sql_one = "select " . $columns_one[(string) $one_array[1]] . "," . $columns_one[(string) $one_array[2]] . " from " . $one_array[0] . "";
break;
default:
$sql_one = "select " . $columns_one[(string) $one_array[1]] . "," . $columns_one[(string) $one_array[2]] . " from " . $one_array[0] . "";
break;
}
break;
case 'mssql':
switch ($one_array[3]) {
case 'name':
$sql_one = "select [" . $columns_one[(string) $one_array[1]] . "],[" . $columns_one[(string) $one_array[2]] . "] from [" . $one_array[0] . "] where [" . $columns_one[(string) $one_array[4]] . "]='" . $USER_NAME . "'";
break;
case 'id':
$sql_one = "select [" . $columns_one[(string) $one_array[1]] . "],[" . $columns_one[(string) $one_array[2]] . "] from [" . $one_array[0] . "]";
break;
default:
$sql_one = "select [" . $columns_one[(string) $one_array[1]] . "],[" . $columns_one[(string) $one_array[2]] . "] from [" . $one_array[0] . "]";
break;
}
break;
}
//print $sql_one;
$rs_one = $db->CacheExecute(150, $sql_one);
if ($rs_one->RecordCount() == 0) {
print_infor($common_html['common_html']['norecord'], 'trip');
exit;
}
while (!$rs_one->EOF) {
if (StrLen($link_array[3]) > 2) {
$LinkIndexName = (string) $link_array[3];
} else {
$LinkIndexName = $columns[(string) $link_array[3]];
}
$url = $link_array[0] . "?" . $link_array[1] . "=" . $link_array[2] . "&" . $LinkIndexName . "=" . $rs_one->fields[(string) $columns_one[(string) $one_array[1]]];
print "\n\t<TABLE class=small cellSpacing=1 cellPadding=0 width='100%' align=center bgColor=#000000 border=0>\n\t<TBODY>\n\t<TR class=TableContent title='' style='CURSOR: hand'\t onclick=clickMenu('{$url}')>\n\t<TD noWrap align=middle><table class=small cellPadding=3 align=center width=100% border=0 onmouseover=bgColor='#ffffff' onmouseout=bgColor='#d3e5fa'>\n\t<Tr><td align=middle><B>" . $rs_one->fields[(string) $columns_one[(string) $one_array[2]]] . "</B></TD></TR>\n\t</table></TD></TR>\n\t</TBODY></TABLE>\n";
$rs_one->MoveNext();
}
}
示例3: 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));
}
示例4: WriteData
private function WriteData($Command, $String = "")
{
$Data = Pack('VV', $this->RequestId++, $Command) . $String . "";
$Data = Pack('V', StrLen($Data)) . $Data;
$Length = StrLen($Data);
return $Length === FWrite($this->Socket, $Data, $Length);
}
示例5: sendMes
/**
* @param int $idUserFrom
* @param int $idUserTo
* @param string $title
* @param string $type
* @param string $idQuestion
* @param string $textMessage
* @return int
*/
public static function sendMes($idUserFrom = 1, $idUserTo = 1, $title, $idQuestion, $textMessage = "", $type = "P")
{
$res = false;
$senderUserID = $idUserFrom;
$targetUserID = $idUserTo;
$arFieldsMes = array("FROM_USER_ID" => $senderUserID, "TO_USER_ID" => $targetUserID, "TITLE" => $title, "MESSAGE" => $idQuestion, "DATE_CREATE" => date("d.m.Y H:i:s", time() - DIFFERENT_WITH_MOSCOW_TIME), "DATE_VIEW" => false, "MESSAGE_TYPE" => $type, "FROM_DELETED" => "N", "TO_DELETED" => "N", "SEND_MAIL" => "Y");
if (CModule::IncludeModule("socialnetwork")) {
$res = CSocNetMessages::Add($arFieldsMes);
if ($res) {
if (CModule::IncludeModule("iblock")) {
if (CModule::IncludeModule('payments')) {
$userInfo = new CLawPayment();
$InfoUserFrom = $userInfo->userInfo($idUserFrom);
$InfoUserTo = $userInfo->userInfo($idUserTo);
$emailFrom = $InfoUserFrom["EMAIL"];
$emailUser = $InfoUserTo["EMAIL"];
SendMessage::sendMessOnEmail($emailFrom, $emailUser, $title, $textMessage);
}
}
} else {
$errorMessage = "";
if ($err = $GLOBALS["APPLICATION"]->GetException()) {
$errorMessage = $err->GetString();
}
if (StrLen($errorMessage) <= 0) {
$errorMessage = GetMessage("SONET_UR_ERROR_CREATE_MESSAGE");
}
$GLOBALS["APPLICATION"]->ThrowException($errorMessage, "ERROR_CREATE_MESSAGE");
}
}
return $res;
}
示例6: CheckFields
function CheckFields($ACTION, &$arFields, $ID = 0)
{
if ((is_set($arFields, "SITE_ID") || $ACTION == "ADD") && StrLen($arFields["SITE_ID"]) <= 0) {
$GLOBALS["APPLICATION"]->ThrowException(GetMessage("SCGAT1_NO_SITE"), "EMPTY_SITE_ID");
return false;
}
if (is_set($arFields, "RATE1")) {
$arFields["RATE1"] = str_replace(",", ".", $arFields["RATE1"]);
$arFields["RATE1"] = DoubleVal($arFields["RATE1"]);
}
if (is_set($arFields, "RATE2")) {
$arFields["RATE2"] = str_replace(",", ".", $arFields["RATE2"]);
$arFields["RATE2"] = DoubleVal($arFields["RATE2"]);
}
if (is_set($arFields, "RATE3")) {
$arFields["RATE3"] = str_replace(",", ".", $arFields["RATE3"]);
$arFields["RATE3"] = DoubleVal($arFields["RATE3"]);
}
if (is_set($arFields, "RATE4")) {
$arFields["RATE4"] = str_replace(",", ".", $arFields["RATE4"]);
$arFields["RATE4"] = DoubleVal($arFields["RATE4"]);
}
if (is_set($arFields, "RATE5")) {
$arFields["RATE5"] = str_replace(",", ".", $arFields["RATE5"]);
$arFields["RATE5"] = DoubleVal($arFields["RATE5"]);
}
return True;
}
示例7: Read
/**
* @param int $Length
* @throws AuthenticationException
* @return bool
*/
public function Read($Length = 1400)
{
// GoldSource RCON has same structure as Query
$Buffer = $this->Socket->Read();
$StringBuffer = '';
$ReadMore = false;
// There is no indentifier of the end, so we just need to continue reading
do {
$ReadMore = $Buffer->Remaining() > 0;
if ($ReadMore) {
if ($Buffer->GetByte() !== SourceQuery::S2A_RCON) {
throw new InvalidPacketException('Invalid rcon response.', InvalidPacketException::PACKET_HEADER_MISMATCH);
}
$Packet = $Buffer->Get();
$StringBuffer .= $Packet;
//$StringBuffer .= 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?
if ($ReadMore) {
$Buffer = $this->Socket->Read();
}
}
} while ($ReadMore);
$Trimmed = trim($StringBuffer);
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);
}
}
$Buffer->Set($Trimmed);
return $Buffer;
}
示例8: Sherlock
public function Sherlock($Buffer, $Length)
{
$Data = FRead($this->Socket, $Length);
if (StrLen($Data) < 4) {
return false;
}
$Buffer->Set($Data);
return $Buffer->GetLong() === -2;
}
示例9: SonetDebugTmp
function SonetDebugTmp($var, $name = "")
{
$fff = fopen($_SERVER["DOCUMENT_ROOT"] . "/~test.tmp", "a");
if (is_array($var)) {
fwrite($fff, (StrLen($name) > 0 ? $name . ":\n" : "") . print_r($var, true) . "\n\n");
} else {
fwrite($fff, (StrLen($name) > 0 ? $name . "=" : "") . $var . "\n\n");
}
fclose($fff);
}
示例10: generate_pass
public function generate_pass($maxlength = 10)
{
$chars = "qazxswedcvfrtgbnhyujmkiolp1234567890QAZXSWEDCVFRTGBNHYUJMKIOLP";
$size = StrLen($chars) - 1;
$pass = '';
while ($maxlength--) {
$pass .= $chars[rand(0, $size)];
}
return $pass;
}
示例11: _generated
function _generated()
{
$chars = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ!?@#$%&*[]{}();:,<>~+=-_/|\\';
// набор символов
$max = 4;
$size = StrLen($chars) - 1;
$hash = null;
while ($max--) {
$hash .= $chars[rand(0, $size)];
}
return $hash;
}
示例12: generatePassword
/**
* Генерация случайного пароля
*/
public function generatePassword($maxChars)
{
$chars = "qazxswedcvfrtgbnhyujmkiolp1234567890QAZXSWEDCVFRTGBNHYUJMKIOLP";
// Определяем количество символов в $chars
$size = StrLen($chars) - 1;
// Определяем пустую переменную, в которую и будем записывать символы.
$password = null;
// Создаём пароль.
while ($maxChars--) {
$password .= $chars[rand(0, $size)];
}
return $password;
}
示例13: 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));
}
示例14: SaXoro
function SaXoro($s, $key)
{
$n = 0;
for ($f = 0; $f < strlen($s); $f++) {
if ($s[$f] != $key[$n]) {
$s[$f] = Chr(ord($s[$f]) ^ ord($key[$n]));
}
$n = $n + 1;
if ($n >= StrLen($key)) {
$n = 0;
}
}
return $s;
}
示例15: RequireAutoloadClass
static function RequireAutoloadClass($className)
{
$className = Trim($className);
if (StrLen($className) <= 0)
return False;
$className = strtolower($className);
if (array_key_exists($className, $GLOBALS["arBitrixModuleClasses"]))
{
require_once($_SERVER["DOCUMENT_ROOT"].((StrLen($GLOBALS["arBitrixModuleClasses"][$className]["module"]) > 0) ? BX_ROOT."/modules/".$GLOBALS["arBitrixModuleClasses"][$className]["module"]."/" : "").$GLOBALS["arBitrixModuleClasses"][$className]["file"]);
return True;
}
return False;
}