The string Chr () function of PHP is used

Source: Internet
Author: User
Tags ord

Chr
  • (PHP 4, PHP 5, PHP 7)
  • Chr-return a specific character
  • chr-returns the specified character
Description
chr($ascii)//Returns a one-character string containing the character specified by ascii.//返回相对应于 ascii 所指定的单个字符。//This function complements ord().//此函数与 ord() 是互补的。
Parametersascii
    • The extended ASCII code.
    • Ascii code.

    • Values outside the valid range (0..255) would be a bitwise and ' Ed with 255, which was equivalent to the following algorithm:

      while($ascii0) {$ascii256;}$ascii256;
Return Values
    • Returns the specified character.
    • Returns the specified character.
Examples
<?php/*** Created by Phpstorm.* User:zhangrongxiang* DATE:2018/2/15* Time: PM 6:56 */ for ( $i= $; $i<127; $i++){Echo CHR( $i ).' ';    if ( $i%Ten==0 ){Echo Php_eol;}}/** A B C D E F* G H I J K L M N O P* Q R S T U V W X Y Z* [\] ^ _ ' a B c D* E F g h i j k l m N* O p q R S t u v w x* y z {|} ~ */Echo Php_eol;functionUnichr( $dec ){if ( $dec< - ){$utf=CHR( $dec );}Else if ( $dec<2048 ){$utf=CHR( 192+( ( $dec-( $dec% - ) )/ - ) );        $utf.=CHR(  -+( $dec% - ) );}Else{$utf=CHR( 224+( ( $dec-( $dec%4096 ) )/4096 ) );        $utf.=CHR(  -+( ( ( $dec%4096 )-( $dec% - ) )/ - ) );        $utf.=CHR(  -+( $dec% - ) );}return $utf;}//MediumEchoUnichr( 20013 ).Php_eol;//aEcho CHR( 321 ).Php_eol;//a + + = 321functionGenpass( $len=8 ){$passwd='';     for ( $i=0; $i<=$len; $i++){$passwd=sprintf( '%s%c ', isset( $passwd ) ? $passwd : NULL, Rand(  -, 122 ) );}return $passwd;}//vutr<oun;EchoGenpass( 8 ).Php_eol;functionUnichr2( $dec ){if ( $dec<0x80 ){$utf=CHR( $dec );}Else if ( $dec<0x0800 ){$utf=CHR( 0xC0+( $dec>>6 ) );        $utf.=CHR( 0x80+( $dec&0x3f ) );}Else if ( $dec<0x010000 ){$utf=CHR( 0xE0+( $dec>> A ) );        $utf.=CHR( 0x80+( ( $dec>>6 )&0x3f ) );        $utf.=CHR( 0x80+( $dec&0x3f ) );}Else if ( $dec<0x200000 ){$utf=CHR( 0xF0+( $dec>> - ) );        $utf.=CHR( 0x80+( ( $dec>> A )&0x3f ) );        $utf.=CHR( 0x80+( ( $dec>>6 )&0x3f ) );        $utf.=CHR( 0x80+( $dec&0x3f ) );}Else{ die( "UTF-8 character size is more than 4 bytes" );}return $utf;}functionUnichr3( $u ){return mb_convert_encoding( ' the '.intval( $u ).';', ' UTF-8 ', ' Html-entities ' );}EchoUnichr( 0x263a ).Php_eol;//?EchoUnichr2( 0x263a ).Php_eol;//?EchoUnichr3( 0x263a ).Php_eol;//?EchoUnichr( 0x263b ).Php_eol;//?EchoUnichr2( 0x263b ).Php_eol;//?EchoUnichr( 20013 ).Php_eol;//MediumEchoUnichr2( 20013 ).Php_eol;//MediumEchoUnichr3( 20013 ).Php_eol;//Medium
See
    • http://php.net/manual/en/function.chr.php
All rights reserved

The string Chr () function of PHP is used

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.