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


PHP strLen函数代码示例

本文整理汇总了PHP中strLen函数的典型用法代码示例。如果您正苦于以下问题:PHP strLen函数的具体用法?PHP strLen怎么用?PHP strLen使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


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

示例1: siemens_push_str

function siemens_push_str($phone_ip, $postdata)
{
    $prov_host = gs_get_conf('GS_PROV_HOST');
    $data = "POST /server_push.html/ServerPush HTTP/1.1\r\n";
    $data .= "User-Agent: Gemeinschaft\r\n";
    $data .= "Host: {$phone_ip}:8085\r\n";
    $data .= "Accept: text/html, image/gif, image/jpeg, *; q=.2, */*; q=.2\r\n";
    $data .= "Connection: keep-alive\r\n";
    $data .= "Content-Type: application/x-www-form-urlencoded\r\n";
    $data .= "Content-Length: " . strLen($postdata) . "\r\n\r\n";
    $data .= $postdata;
    $socket = @fSockOpen($phone_ip, 8085, $error_no, $error_str, 4);
    if (!$socket) {
        gs_log(GS_LOG_NOTICE, "Siemens: Failed to open socket - IP: {$phone_ip}");
        return 0;
    }
    stream_set_timeout($socket, 4);
    $bytes_written = (int) @fWrite($socket, $data, strLen($data));
    @fFlush($socket);
    $response = @fGetS($socket);
    @fClose($socket);
    if (strPos($response, '200') === false) {
        gs_log(GS_LOG_WARNING, "Siemens: Failed to push to phone {$phone_ip}");
        return 0;
    }
    gs_log(GS_LOG_DEBUG, "Siemens: Pushed {$bytes_written} bytes to phone {$phone_ip}");
    return $bytes_written;
}
开发者ID:hehol,项目名称:GemeinschaftPBX,代码行数:28,代码来源:siemens-fns.php

示例2: init

 public function init(Website $website, Request $request)
 {
     $this->keyword = trim($request->getRequestString("searchbox"));
     $this->pageNumber = $request->getRequestInt("page", 0);
     $this->showEditLinks = $website->isLoggedInAsStaff();
     if (strLen($this->keyword) < self::MIN_SEARCH_LENGTH) {
         // Don't search for too short words
         if (!empty($this->keyword)) {
             $website->addError($website->t("articles.search_term") . " " . $website->tReplaced("errors.is_too_short_num", self::MIN_SEARCH_LENGTH));
         }
         return;
     }
     // Fetch article count
     $articles = new ArticleRepository($website);
     $this->totalResults = $articles->getMatchesFor($this->keyword);
     // Count total number of pages, limit current page number
     $this->highestPageNumber = floor($this->totalResults / self::ARTICLES_PER_PAGE);
     if ($this->pageNumber < 0 || $this->pageNumber > $this->highestPageNumber) {
         $this->pageNumber = 0;
     }
     // Fetch articles
     $this->displayedArticles = $articles->getArticlesDataMatch($this->keyword, self::ARTICLES_PER_PAGE, $this->pageNumber * self::ARTICLES_PER_PAGE);
     // Fetch links
     $menus = new LinkRepository($website->getDatabase());
     $this->links = $menus->getLinksBySearch($this->keyword);
 }
开发者ID:rutgerkok,项目名称:rCMS,代码行数:26,代码来源:SearchPage.php

示例3: execute

 public function execute()
 {
     $minLength = $this->annotationValue;
     if (strLen($this->annotatedPropertyValue) < $minLength) {
         throw new \Exception("{$this->annotatedProperty} must be atleast {$minLength} character(s) long", 400);
     }
 }
开发者ID:vNikolov95,项目名称:SoftUni-Web-Development-Basics-Exam,代码行数:7,代码来源:MinLength.php

示例4: grandstream_binary_output

function grandstream_binary_output($header, $body)
{
    # $body length must be divisible by 2
    if (strLen($body) % 2 == 1) {
        $body .= chr(0);
    }
    # get length
    $body_length = strLen($body);
    $header_length = count($header);
    $out_length = $header_length + $body_length;
    // 00 01 02 03 - out_length / 2
    $header[0] = $out_length / 2 >> 24 & 0xff;
    $header[1] = $out_length / 2 >> 16 & 0xff;
    $header[2] = $out_length / 2 >> 8 & 0xff;
    $header[3] = $out_length / 2 & 0xff;
    # assemble output
    $arr = $header;
    array_unshift($arr, 'C' . $header_length);
    $initstr = call_user_func_array('pack', $arr);
    $checktext = $initstr . $body;
    array_splice($header, 4, 2, grandstream_binary_output_checksum($checktext));
    $arr = $header;
    array_unshift($arr, 'C' . $header_length);
    $initstr = call_user_func_array('pack', $arr);
    $out = $initstr . $body;
    return $out;
}
开发者ID:rkania,项目名称:GS3,代码行数:27,代码来源:grandstream-fns.php

示例5: hash

 /**
  * Hashes the string using blowfish or md5, depending on what this server
  * supports. The hash is salted.
  * @param string $string The string to hash.
  */
 public static function hash($string)
 {
     if (CRYPT_BLOWFISH) {
         // Blowfish
         if (version_compare(PHP_VERSION, "5.3.7", '>')) {
             $salt = '$2y$11$' . self::randomString(22);
         } else {
             $salt = '$2a$11$' . self::randomString(22);
         }
         $hashed = crypt($string, $salt);
         if (strLen($hashed) >= self::CRYPT_RETURN_VALUE_MIN_LENGHT) {
             return $hashed;
         }
     }
     if (CRYPT_MD5) {
         // Salted md5
         $salt = '$1$' . static::randomString(8) . '$';
         $hashed = crypt($string, $salt);
         if (strLen($hashed) >= self::CRYPT_RETURN_VALUE_MIN_LENGHT) {
             return $hashed;
         }
     }
     // Try the default algorithm
     $hashed = crypt($string);
     if (stLen($hashed) >= self::CRYPT_RETURN_VALUE_MIN_LENGHT) {
         return $hashed;
     }
     // Failure
     throw new Exception("Hashing of string failed");
 }
开发者ID:rutgerkok,项目名称:rCMS,代码行数:35,代码来源:HashHelper.php

示例6: _out

function _out($str)
{
    @header('Expires: ' . @gmDate('D, d M Y h:i:s', time() + 30) . ' GMT');
    @header('Content-Length: ' . strLen($str));
    echo $str;
    exit;
}
开发者ID:rkania,项目名称:GS3,代码行数:7,代码来源:host-by-extension.php

示例7: canBeSaved

 protected function canBeSaved(Entity $menu)
 {
     if (!$menu instanceof Menu) {
         return false;
     }
     return parent::canBeSaved($menu) && strLen($menu->getName()) > 0 && strLen($menu->getName()) <= self::NAME_MAX_LENGTH;
 }
开发者ID:rutgerkok,项目名称:rCMS,代码行数:7,代码来源:MenuRepository.php

示例8: gs_agent_update

function gs_agent_update($agent, $pin = '', $name, $firstname)
{
    if (!preg_match('/^\\d+$/', $agent)) {
        return new GsError('User must be numeric.');
    }
    if (strlen($pin) > 0 && !preg_match('/^[0-9]+$/', $pin)) {
        return new GsError('PIN must be numeric.');
    } elseif (strLen($pin) > 10) {
        return new GsError('PIN too long (max. 10 digits).');
    }
    $name = preg_replace('/\\s+/', ' ', trim($name));
    $firstname = preg_replace('/\\s+/', ' ', trim($firstname));
    # connect to db
    #
    $db = gs_db_master_connect();
    if (!$db) {
        return new GsError('Could not connect to database.');
    }
    # get agent_id
    #
    $agent_id = $db->executeGetOne('SELECT `id` FROM `agents` WHERE `number`=\'' . $db->escape($agent) . '\'');
    if (!$agent_id) {
        return new GsError('Unknown user.');
    }
    # set PIN
    #
    $ok = $db->execute('UPDATE `agents` SET `pin`=\'' . $db->escape($pin) . '\', `name`=\'' . $db->escape($name) . '\', `firstname`=\'' . $db->escape($firstname) . '\' WHERE `id`=' . $agent_id);
    if (!$ok) {
        return new GsError('Failed to set PIN.');
    }
    return true;
}
开发者ID:hehol,项目名称:GemeinschaftPBX,代码行数:32,代码来源:gs_agent_update.php

示例9: init

 function init()
 {
     $this->username = CSalePaySystemAction::GetParamValue("USER");
     $this->pwd = CSalePaySystemAction::GetParamValue("PWD");
     $this->signature = CSalePaySystemAction::GetParamValue("SIGNATURE");
     $this->currency = CSalePaySystemAction::GetParamValue("CURRENCY");
     $this->testMode = CSalePaySystemAction::GetParamValue("TEST") == "Y";
     if ($this->testMode) {
         $this->domain = "sandbox.";
     }
     if (strlen($_REQUEST["token"]) > 0) {
         $this->token = $_REQUEST["token"];
     }
     if (strlen($_REQUEST["PayerID"]) > 0) {
         $this->payerId = $_REQUEST["PayerID"];
     }
     $this->version = "98.0";
     $dbSite = CSite::GetByID(SITE_ID);
     $arSite = $dbSite->Fetch();
     $this->serverName = $arSite["SERVER_NAME"];
     if (strLen($this->serverName) <= 0) {
         if (defined("SITE_SERVER_NAME") && strlen(SITE_SERVER_NAME) > 0) {
             $this->serverName = SITE_SERVER_NAME;
         } else {
             $this->serverName = COption::GetOptionString("main", "server_name", "www.bitrixsoft.com");
         }
     }
     $this->serverName = (CMain::IsHTTPS() ? "https" : "http") . "://" . $this->serverName;
     if (strlen($this->username) <= 0 || strlen($this->username) <= 0 || strlen($this->username) <= 0) {
         $GLOBALS["APPLICATION"]->ThrowException("CSalePaySystempaypal: init error", "CSalePaySystempaypal_init_error");
         return false;
     }
     return true;
 }
开发者ID:k-kalashnikov,项目名称:geekcon_new,代码行数:34,代码来源:pre_payment.php

示例10: checkFieldLength

 /**
  * determines if the trimmed value is not the empty string.
  * @param String $field the field name used by the associative superglobal array.
  * @return boolean $Length if length is greater than 0
  */
 public function checkFieldLength($field)
 {
     if (isset($_SESSION[$fieldName])) {
         return strLen(trim($_SESSION[$fieldName]));
     } else {
         return false;
     }
 }
开发者ID:zedd45,项目名称:artdecostylesandcuts,代码行数:13,代码来源:FrontendValidation.php

示例11: convertIndentationSpaces

 /**
  * @return string
  * @param string $source
  */
 protected function convertIndentationSpaces($source)
 {
     $callBack = function ($matches) {
         $count = strLen($matches[1]) / 4;
         return str_repeat("\t", $count);
     };
     return preg_replace_callback("/^((?:    )+)/m", $callBack, $source);
 }
开发者ID:visor,项目名称:nano,代码行数:12,代码来源:fix-spaces.php

示例12: isAtTheEnd

function isAtTheEnd($mainStr, $subStr)
{
    if (strlen($mainStr) >= strLen($subStr)) {
        return strrpos($mainStr, $subStr, strlen($mainStr) - strlen($subStr)) !== false;
    } else {
        return false;
    }
}
开发者ID:NiccoVi,项目名称:bwinf-releases,代码行数:8,代码来源:index.php

示例13: WrapLongWords

 function WrapLongWords($text = "")
 {
     if (strLen($text) <= 40) {
         return $text;
     }
     $word_separator = "\\s.,;:!?\\#\\*\\|\\[\\]\\(\\)";
     $text = preg_replace_callback("/(?<=[" . $word_separator . "])(([^" . $word_separator . "]+))(?=[" . $word_separator . "])/is" . BX_UTF_PCRE_MODIFIER, '__wrapLongWords', " " . $text . " ");
     return trim($text);
 }
开发者ID:mrdeadmouse,项目名称:u136006,代码行数:9,代码来源:functions.php

示例14: InitRecordCall

function InitRecordCall($filename, $index, $comment)
{
    //FIXME
    $user = gs_user_get($_SESSION['sudo_user']['name']);
    $call = "Channel: SIP/" . $_SESSION['sudo_user']['info']['ext'] . "\n" . "MaxRetries: 0\n" . "WaitTime: 15\n" . "Context: vm-rec-multiple\n" . "Extension: webdialrecord\n" . "Callerid: {$comment} <Aufnahme>\n" . "Setvar: __user_id=" . $_SESSION['sudo_user']['info']['id'] . "\n" . "Setvar: __user_name=" . $_SESSION['sudo_user']['info']['ext'] . "\n" . "Setvar: CHANNEL(language)=" . gs_get_conf('GS_INTL_ASTERISK_LANG', 'de') . "\n" . "Setvar: __is_callfile_origin=1\n" . "Setvar: __callfile_from_user=" . $_SESSION['sudo_user']['info']['ext'] . "\n" . "Setvar: __record_file=" . $filename . "\n";
    $filename = '/tmp/gs-' . $_SESSION['sudo_user']['info']['id'] . '-' . _pack_int(time()) . rand(100, 999) . '.call';
    $cf = @fOpen($filename, 'wb');
    if (!$cf) {
        gs_log(GS_LOG_WARNING, 'Failed to write call file "' . $filename . '"');
        echo 'Failed to write call file.';
        die;
    }
    @fWrite($cf, $call, strLen($call));
    @fClose($cf);
    @chmod($filename, 0666);
    $spoolfile = '/var/spool/asterisk/outgoing/' . baseName($filename);
    if (!gs_get_conf('GS_INSTALLATION_TYPE_SINGLE')) {
        $our_host_ids = @gs_get_listen_to_ids();
        if (!is_array($our_host_ids)) {
            $our_host_ids = array();
        }
        $user_is_on_this_host = in_array($_SESSION['sudo_user']['info']['host_id'], $our_host_ids);
    } else {
        $user_is_on_this_host = true;
    }
    if ($user_is_on_this_host) {
        # the Asterisk of this user and the web server both run on this host
        $err = 0;
        $out = array();
        @exec('sudo mv ' . qsa($filename) . ' ' . qsa($spoolfile) . ' 1>>/dev/null 2>>/dev/null', $out, $err);
        if ($err != 0) {
            @unlink($filename);
            gs_log(GS_LOG_WARNING, 'Failed to move call file "' . $filename . '" to "' . '/var/spool/asterisk/outgoing/' . baseName($filename) . '"');
            echo 'Failed to move call file.';
            die;
        }
    } else {
        $cmd = 'sudo scp -o StrictHostKeyChecking=no -o BatchMode=yes ' . qsa($filename) . ' ' . qsa('root@' . $user['host'] . ':' . $filename);
        //echo $cmd, "\n";
        @exec($cmd . ' 1>>/dev/null 2>>/dev/null', $out, $err);
        @unlink($filename);
        if ($err != 0) {
            gs_log(GS_LOG_WARNING, 'Failed to scp call file "' . $filename . '" to ' . $user['host']);
            echo 'Failed to scp call file.';
            die;
        }
        //remote_exec( $user['host'], $cmd, 10, $out, $err ); // <-- does not use sudo!
        $cmd = 'sudo ssh -o StrictHostKeyChecking=no -o BatchMode=yes -l root ' . qsa($user['host']) . ' ' . qsa('mv ' . qsa($filename) . ' ' . qsa($spoolfile));
        //echo $cmd, "\n";
        @exec($cmd . ' 1>>/dev/null 2>>/dev/null', $out, $err);
        if ($err != 0) {
            gs_log(GS_LOG_WARNING, 'Failed to mv call file "' . $filename . '" on ' . $user['host'] . ' to "' . $spoolfile . '"');
            echo 'Failed to mv call file on remote host.';
            die;
        }
    }
}
开发者ID:rkania,项目名称:GS3,代码行数:57,代码来源:forwards_queues.php

示例15: xml_output

function xml_output()
{
    global $xml_buf;
    @header('X-Powered-By: Gemeinschaft');
    @header('Content-Type: text/xml; charset=utf-8');
    @header('Content-Length: ' . strLen($xml_buf));
    echo $xml_buf;
    exit;
}
开发者ID:rkania,项目名称:GS3,代码行数:9,代码来源:pb.php


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