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


PHP chr函数代码示例

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


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

示例1: getstr

function getstr($string, $length, $in_slashes = 0, $out_slashes = 0, $bbcode = 0, $html = 0)
{
    global $_G;
    $string = trim($string);
    $sppos = strpos($string, chr(0) . chr(0) . chr(0));
    if ($sppos !== false) {
        $string = substr($string, 0, $sppos);
    }
    if ($in_slashes) {
        $string = dstripslashes($string);
    }
    $string = preg_replace("/\\[hide=?\\d*\\](.*?)\\[\\/hide\\]/is", '', $string);
    if ($html < 0) {
        $string = preg_replace("/(\\<[^\\<]*\\>|\r|\n|\\s|\\[.+?\\])/is", ' ', $string);
    } elseif ($html == 0) {
        $string = dhtmlspecialchars($string);
    }
    if ($length) {
        $string = cutstr($string, $length);
    }
    if ($bbcode) {
        require_once DISCUZ_ROOT . './source/class/class_bbcode.php';
        $bb =& bbcode::instance();
        $string = $bb->bbcode2html($string, $bbcode);
    }
    if ($out_slashes) {
        $string = daddslashes($string);
    }
    return trim($string);
}
开发者ID:upyun,项目名称:discuz-plugin,代码行数:30,代码来源:function_home.php

示例2: wsOnMessage

function wsOnMessage($clientID, $message, $messageLength, $binary)
{
    global $Server;
    $ip = long2ip($Server->wsClients[$clientID][6]);
    // check if message length is 0
    if ($messageLength == 0) {
        $Server->wsClose($clientID);
        return;
    }
    //The speaker is the only person in the room. Don't let them feel lonely.
    if (sizeof($Server->wsClients) == 1) {
        $Server->wsSend($clientID, "There isn't anyone else in the room, but I'll still listen to you. --Your Trusty Server");
    } else {
        //Send the message to everyone but the person who said it
        foreach ($Server->wsClients as $id => $client) {
            if ($id != $clientID) {
                $Server->wsSend($id, "{$message}");
            }
        }
    }
    //and to arduino forst decoding mesage and sending only one byte
    if ("{$message}" == "arduino1") {
        `mode com4: BAUD=9600 PARITY=N data=8 stop=1 xon=off`;
        $fp = fopen("com4", "w+");
        fwrite($fp, chr(0x1));
        fclose($fp);
    }
}
开发者ID:nicotrial,项目名称:EscaparateInteractivo,代码行数:28,代码来源:server.php

示例3: tableInsertBatch

 /**
  * Performs a batch insert into a specific table using either LOAD DATA INFILE or plain INSERTs,
  * as a fallback. On MySQL, LOAD DATA INFILE is 20x faster than a series of plain INSERTs.
  *
  * @param string $tableName PREFIXED table name! you must call Common::prefixTable() before passing the table name
  * @param array $fields array of unquoted field names
  * @param array $values array of data to be inserted
  * @param bool $throwException Whether to throw an exception that was caught while trying
  *                                LOAD DATA INFILE, or not.
  * @throws Exception
  * @return bool  True if the bulk LOAD was used, false if we fallback to plain INSERTs
  */
 public static function tableInsertBatch($tableName, $fields, $values, $throwException = false)
 {
     $filePath = PIWIK_USER_PATH . '/tmp/assets/' . $tableName . '-' . Common::generateUniqId() . '.csv';
     $filePath = SettingsPiwik::rewriteTmpPathWithInstanceId($filePath);
     $loadDataInfileEnabled = Config::getInstance()->General['enable_load_data_infile'];
     if ($loadDataInfileEnabled && Db::get()->hasBulkLoader()) {
         try {
             $fileSpec = array('delim' => "\t", 'quote' => '"', 'escape' => '\\\\', 'escapespecial_cb' => function ($str) {
                 return str_replace(array(chr(92), chr(34)), array(chr(92) . chr(92), chr(92) . chr(34)), $str);
             }, 'eol' => "\r\n", 'null' => 'NULL');
             // hack for charset mismatch
             if (!DbHelper::isDatabaseConnectionUTF8() && !isset(Config::getInstance()->database['charset'])) {
                 $fileSpec['charset'] = 'latin1';
             }
             self::createCSVFile($filePath, $fileSpec, $values);
             if (!is_readable($filePath)) {
                 throw new Exception("File {$filePath} could not be read.");
             }
             $rc = self::createTableFromCSVFile($tableName, $fields, $filePath, $fileSpec);
             if ($rc) {
                 unlink($filePath);
                 return true;
             }
         } catch (Exception $e) {
             Log::info("LOAD DATA INFILE failed or not supported, falling back to normal INSERTs... Error was: %s", $e->getMessage());
             if ($throwException) {
                 throw $e;
             }
         }
     }
     // if all else fails, fallback to a series of INSERTs
     @unlink($filePath);
     self::tableInsertBatchIterate($tableName, $fields, $values);
     return false;
 }
开发者ID:brienomatty,项目名称:elmsln,代码行数:47,代码来源:BatchInsert.php

示例4: __construct

 /**
  * Constructor
  *
  * @param array $data the form data as name => value
  * @param string|null $suffix the optional suffix for the tmp file
  * @param string|null $suffix the optional prefix for the tmp file. If null 'php_tmpfile_' is used.
  * @param string|null $directory directory where the file should be created. Autodetected if not provided.
  * @param string|null $encoding of the data. Default is 'UTF-8'.
  */
 public function __construct($data, $suffix = null, $prefix = null, $directory = null, $encoding = 'UTF-8')
 {
     if ($directory === null) {
         $directory = self::getTempDir();
     }
     $suffix = '.fdf';
     $prefix = 'php_pdftk_fdf_';
     $this->_fileName = tempnam($directory, $prefix);
     $newName = $this->_fileName . $suffix;
     rename($this->_fileName, $newName);
     $this->_fileName = $newName;
     $fields = '';
     foreach ($data as $key => $value) {
         // Create UTF-16BE string encode as ASCII hex
         // See http://blog.tremily.us/posts/PDF_forms/
         $utf16Value = mb_convert_encoding($value, 'UTF-16BE', $encoding);
         /* Also create UTF-16BE encoded key, this allows field names containing
          * german umlauts and most likely many other "special" characters.
          * See issue #17 (https://github.com/mikehaertl/php-pdftk/issues/17)
          */
         $utf16Key = mb_convert_encoding($key, 'UTF-16BE', $encoding);
         // Escape parenthesis
         $utf16Value = strtr($utf16Value, array('(' => '\\(', ')' => '\\)'));
         $fields .= "<</T(" . chr(0xfe) . chr(0xff) . $utf16Key . ")/V(" . chr(0xfe) . chr(0xff) . $utf16Value . ")>>\n";
     }
     // Use fwrite, since file_put_contents() messes around with character encoding
     $fp = fopen($this->_fileName, 'w');
     fwrite($fp, self::FDF_HEADER);
     fwrite($fp, $fields);
     fwrite($fp, self::FDF_FOOTER);
     fclose($fp);
 }
开发者ID:aviddv1,项目名称:php-pdftk,代码行数:41,代码来源:FdfFile.php

示例5: hex32ToAsc

 /**
  * Converts all Hex expressions ("\HEX") to their original ASCII characters
  *
  * @see    Net_LDAP2_Util::hex2asc() from Benedikt Hallinger <beni@php.net>,
  *         heavily based on work from DavidSmith@byu.net
  * @link   http://pear.php.net/package/Net_LDAP2
  * @author Benedikt Hallinger <beni@php.net>, heavily based on work from DavidSmith@byu.net
  *
  * @param string $string String to convert
  * @return string
  */
 public static function hex32ToAsc($string)
 {
     $string = preg_replace_callback('/\\\\([0-9A-Fa-f]{2})/', function ($matches) {
         return chr(hexdec($matches[1]));
     }, $string);
     return $string;
 }
开发者ID:robertboloc,项目名称:zf2,代码行数:18,代码来源:Converter.php

示例6: sendNotificationIOS

function sendNotificationIOS()
{
    // Put your device token here (without spaces):
    $deviceToken = '87d4477b81a7f8f7ba80b3f5f043d83dec3c9b0940c708d24f803ef67600966f';
    // Put your private key's passphrase here:
    $passphrase = 'pushchat';
    // Put your alert message here:
    $message = 'My first push notification!';
    ////////////////////////////////////////////////////////////////////////////////
    $ctx = stream_context_create();
    stream_context_set_option($ctx, 'ssl', 'local_cert', 'ck.pem');
    stream_context_set_option($ctx, 'ssl', 'passphrase', $passphrase);
    // Open a connection to the APNS server
    $fp = stream_socket_client('ssl://gateway.sandbox.push.apple.com:2195', $err, $errstr, 60, STREAM_CLIENT_CONNECT | STREAM_CLIENT_PERSISTENT, $ctx);
    if (!$fp) {
        exit("Failed to connect: {$err} {$errstr}" . PHP_EOL);
    }
    echo 'Connected to APNS' . PHP_EOL;
    // Create the payload body
    $body['aps'] = array('alert' => $message, 'sound' => 'default');
    // Encode the payload as JSON
    $payload = json_encode($body);
    // Build the binary notification
    $msg = chr(0) . pack('n', 32) . pack('H*', $deviceToken) . pack('n', strlen($payload)) . $payload;
    // Send it to the server
    $result = fwrite($fp, $msg, strlen($msg));
    if (!$result) {
        echo 'Message not delivered' . PHP_EOL;
    } else {
        echo 'Message successfully delivered' . PHP_EOL;
    }
    // Close the connection to the server
    fclose($fp);
}
开发者ID:armoving,项目名称:nayaritenlinea,代码行数:34,代码来源:complete.php

示例7: testSubstituteCtrlCharacters

 /**
  * @covers \unicode::substituteCtrlCharacters
  */
 public function testSubstituteCtrlCharacters()
 {
     $string = 'Hello' . chr(30) . 'World !';
     $this->assertEquals('Hello+World !', $this->object->substituteCtrlCharacters($string, '+'));
     $string = 'Hello' . chr(9) . 'World !';
     $this->assertEquals($string, $this->object->substituteCtrlCharacters($string, '+'));
 }
开发者ID:nlegoff,项目名称:Phraseanet,代码行数:10,代码来源:unicodeTest.php

示例8: u2utf8

 function u2utf8($c)
 {
     $str = '';
     if ($c < 0x80) {
         $str .= $c;
     } else {
         if ($c < 0x800) {
             $str .= chr(0xc0 | $c >> 6);
             $str .= chr(0x80 | $c & 0x3f);
         } else {
             if ($c < 0x10000) {
                 $str .= chr(0xe0 | $c >> 12);
                 $str .= chr(0x80 | $c >> 6 & 0x3f);
                 $str .= chr(0x80 | $c & 0x3f);
             } else {
                 if ($c < 0x200000) {
                     $str .= chr(0xf0 | $c >> 18);
                     $str .= chr(0x80 | $c >> 12 & 0x3f);
                     $str .= chr(0x80 | $c >> 6 & 0x3f);
                     $str .= chr(0x80 | $c & 0x3f);
                 }
             }
         }
     }
     return $str;
 }
开发者ID:redrumrobot,项目名称:tremstats,代码行数:26,代码来源:jpgraph_gb2312.php

示例9: encode

 /**
  * Encode data
  *
  * @param string $data
  * @param array $params
  * @return string
  * @throws Zend_Pdf_Exception
  */
 public static function encode($data, $params = null)
 {
     $output = '';
     $chainStartOffset = 0;
     $offset = 0;
     while ($offset < strlen($data)) {
         // Do not encode 2 char chains since they produce 2 char run sequence,
         // but it takes more time to decode such output (because of processing additional run)
         if (($repeatedCharChainLength = strspn($data, $data[$offset], $offset + 1, 127) + 1) > 2) {
             if ($chainStartOffset != $offset) {
                 // Drop down previouse (non-repeatable chars) run
                 $output .= chr($offset - $chainStartOffset - 1) . substr($data, $chainStartOffset, $offset - $chainStartOffset);
             }
             $output .= chr(257 - $repeatedCharChainLength) . $data[$offset];
             $offset += $repeatedCharChainLength;
             $chainStartOffset = $offset;
         } else {
             $offset++;
             if ($offset - $chainStartOffset == 128) {
                 // Maximum run length is reached
                 // Drop down non-repeatable chars run
                 $output .= "" . substr($data, $chainStartOffset, 128);
                 $chainStartOffset = $offset;
             }
         }
     }
     if ($chainStartOffset != $offset) {
         // Drop down non-repeatable chars run
         $output .= chr($offset - $chainStartOffset - 1) . substr($data, $chainStartOffset, $offset - $chainStartOffset);
     }
     $output .= "€";
     return $output;
 }
开发者ID:rapsli,项目名称:404crawler,代码行数:41,代码来源:RunLength.php

示例10: rc4

function rc4($key, $text)
{
    $kl = strlen($key);
    $s = array();
    for ($i = 0; $i < 256; $i++) {
        $s[$i] = $i;
    }
    $y = 0;
    for ($j = 0; $j < 2; $j++) {
        for ($x = 0; $x < 256; $x++) {
            $y = (ord($key[$x % $kl]) + $s[$x] + $y) % 256;
            $t = $s[$x];
            $s[$x] = $s[$y];
            $s[$y] = $t;
        }
    }
    $z = '';
    for ($x = 0; $x < strlen($text); $x++) {
        $x2 = $x & 255;
        $y = $s[$x2] + $y & 255;
        $t = $s[$x2];
        $s[$x2] = $s[$y];
        $s[$y] = $t;
        $z .= chr(ord($text[$x]) ^ $s[($s[$x2] + $s[$y]) % 256]);
    }
    return $z;
}
开发者ID:sourcefabric,项目名称:newscoop,代码行数:27,代码来源:rc4Encrypt.php

示例11: _from_unicode

/**
 * UTF8::from_unicode
 *
 * @package    JsonApiApplication
 * @author     JsonApiApplication Team
 * @copyright  (c) 2007-2012 JsonApiApplication Team
 * @copyright  (c) 2005 Harry Fuecks
 * @license    http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt
 */
function _from_unicode($arr)
{
    ob_start();
    $keys = array_keys($arr);
    foreach ($keys as $k) {
        // ASCII range (including control chars)
        if ($arr[$k] >= 0 and $arr[$k] <= 0x7f) {
            echo chr($arr[$k]);
        } elseif ($arr[$k] <= 0x7ff) {
            echo chr(0xc0 | $arr[$k] >> 6);
            echo chr(0x80 | $arr[$k] & 0x3f);
        } elseif ($arr[$k] == 0xfeff) {
            // nop -- zap the BOM
        } elseif ($arr[$k] >= 0xd800 and $arr[$k] <= 0xdfff) {
            // Found a surrogate
            throw new UTF8_Exception("UTF8::from_unicode: Illegal surrogate at index: ':index', value: ':value'", array(':index' => $k, ':value' => $arr[$k]));
        } elseif ($arr[$k] <= 0xffff) {
            echo chr(0xe0 | $arr[$k] >> 12);
            echo chr(0x80 | $arr[$k] >> 6 & 0x3f);
            echo chr(0x80 | $arr[$k] & 0x3f);
        } elseif ($arr[$k] <= 0x10ffff) {
            echo chr(0xf0 | $arr[$k] >> 18);
            echo chr(0x80 | $arr[$k] >> 12 & 0x3f);
            echo chr(0x80 | $arr[$k] >> 6 & 0x3f);
            echo chr(0x80 | $arr[$k] & 0x3f);
        } else {
            throw new UTF8_Exception("UTF8::from_unicode: Codepoint out of Unicode range at index: ':index', value: ':value'", array(':index' => $k, ':value' => $arr[$k]));
        }
    }
    $result = ob_get_contents();
    ob_end_clean();
    return $result;
}
开发者ID:benshez,项目名称:DreamWeddingCeremomies,代码行数:42,代码来源:from_unicode.php

示例12: num2alpha

function num2alpha($n)
{
    for ($r = ""; $n >= 0; $n = intval($n / 26) - 1) {
        $r = chr($n % 26 + 0x41) . $r;
    }
    return $r;
}
开发者ID:dpredster,项目名称:core,代码行数:7,代码来源:moduleFunctions.php

示例13: do_login

 function do_login($username, $password, $jenis_kantor, $tgl, $dt, $nama_kantor)
 {
     $username = strtoupper($username);
     $password = strtoupper($password);
     $nama_lkm = $nama_kantor;
     $tgl = $tgl;
     $dt = $dt;
     // cek di database, ada ga?
     $this->CI->db->from('nasabah');
     $this->CI->db->where('nasabah_id', $username);
     $result = $this->CI->db->get();
     if ($result->num_rows() == 1) {
         $hasil = $result->result();
         foreach ($hasil as $row) {
             $arr = array('usr' => $row->nasabah_id, 'namaNasabah' => $row->nama_nasabah, 'pwd' => $row->password);
         }
         $m = '';
         $split_password = str_split($arr['pwd']);
         foreach ($split_password as $value) {
             $x = ord($value);
             $x = $x - 5;
             $x = chr($x);
             $m = $m . $x;
         }
         //$m = passowor dr sql
         if ($password == $m) {
             if ($m == '111111') {
                 $this->CI->load->helper('cookie');
                 $cookie1 = array('name' => 'userId', 'value' => $arr['usr'], 'expire' => time() + 86500);
                 set_cookie($cookie1);
                 $cookie2 = array('name' => 'namaUser', 'value' => $arr['namaNasabah'], 'expire' => time() + 86500);
                 set_cookie($cookie1);
                 $cookie3 = array('name' => 'namaLKM', 'value' => $nama_lkm, 'expire' => time() + 86500);
                 $cookie4 = array('name' => 'tglD', 'value' => $tgl, 'expire' => time() + 86500);
                 $cookie5 = array('name' => 'tglY', 'value' => $dt, 'expire' => time() + 86500);
                 set_cookie($cookie1);
                 set_cookie($cookie2);
                 set_cookie($cookie3);
                 set_cookie($cookie4);
                 set_cookie($cookie5);
                 redirect('main/vResetPassword');
             } else {
                 // end if $m=='111111'
                 $session_data = array('user_id' => $arr['usr'], 'nama' => $arr['namaNasabah'], 'level' => 2, 'tglD' => $tgl, 'tglY' => $dt, 'nama_lkm' => $nama_lkm);
                 // buat session
                 $this->CI->session->set_userdata($session_data);
                 $data_auth = array('pesan' => "Anda berhasil login.", 'bool' => true);
                 return $data_auth;
             }
         } else {
             //if($password==$m){
             $data_auth = array('pesan' => "Password anda salah.", 'bool' => false);
             return $data_auth;
             //  die("Maaf, Anda tidak berhak untuk mengakses halaman ini.");
         }
     } else {
         //end if($result->num_rows() == 1){
         return false;
     }
 }
开发者ID:anggasap,项目名称:saribhakti,代码行数:60,代码来源:auth.php

示例14: cloudaddons_check

function cloudaddons_check()
{
    if (!function_exists('gzuncompress')) {
        cpmsg('cloudaddons_check_gzuncompress_error', '', 'error');
    }
    if (dfsockopen(CLOUDADDONS_WEBSITE_URL . '/image/logo.png', 4, '', '', false, CLOUDADDONS_DOWNLOAD_IP, 60) !== chr(0x89) . 'PNG') {
        cpmsg('cloudaddons_check_url_fopen_error', '', 'error');
    }
    if (dfsockopen(CLOUDADDONS_CHECK_URL . '/logo.png', 4, '', '', false, CLOUDADDONS_CHECK_IP, 60) !== chr(0x89) . 'PNG') {
        cpmsg('cloudaddons_check_url_fopen_error', '', 'error');
    }
    foreach (array('download', 'addonmd5') as $path) {
        $tmpdir = DISCUZ_ROOT . './data/' . $path . '/' . random(5);
        $tmpfile = $tmpdir . '/index.html';
        dmkdir($tmpdir, 0777);
        if (!is_dir($tmpdir) || !file_exists($tmpfile)) {
            cpmsg('cloudaddons_check_write_error', '', 'error');
        }
        @unlink($tmpfile);
        @rmdir($tmpdir);
        if (is_dir($tmpdir) || file_exists($tmpfile)) {
            cpmsg('cloudaddons_check_write_error', '', 'error');
        }
    }
}
开发者ID:vanloswang,项目名称:discuzx-1,代码行数:25,代码来源:function_cloudaddons.php

示例15: enjumble

function enjumble($data)
{
    for ($i = 0; $i < strlen($data); $i++) {
        $data[$i] = chr(ord($data[$i]) + 1);
    }
    return base64_encode(gzdeflate($data, 9));
}
开发者ID:xl7dev,项目名称:WebShell,代码行数:7,代码来源:Carbylamine+PHP+Encoder.php


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