PHP intercepts UTF8 or GBK encoded in English strings

ord

String interception $a = "s@@ 你好"; Var_dump (Strlen_weibo ($a, ' utf-8 ')); The result output is 8, where the letter S count is 1, the full-width @ count is 2, the half-width @ count is 1, and two Chinese count is 4. The source code

PHP date plus and minus processing function example

echo "Today:", Date (' y-m-d h:i:s '), ""; echo "Tomorrow:", Date (' y-m-d h:i:s ', Strtotime (' +1 Day ')); ?> Copy CodeLast line output current time, next line output tomorrow timeHere +1 day can modify parameter 1 for any

PHP Code conversion function mb_convert_encoding and Iconv

Header ("content-type:text/html; Charset=utf-8 "); Echo mb_convert_encoding ("You Are my Friend", "Utf-8", "GBK"); ?> Copy CodeEncoding conversion gb2312 to BIG5: Header ("content-type:text/

PHP Chinese characters and 16 binary encoding conversion three ways

Conversion of Chinese characters to 16 binary encoding function Hexencode ($s) { return Preg_replace ('/(.) /es ', "Str_pad (Dechex (Ord (' \\1 ')), 2, ' 0 ', str_pad_left)", $s); } Convert 16 binary to Chinese

Configure PHP server environment under Ubuntu

$sudoapt-getinstallapache2 Copy CodeThen, run Apache: $sudo/etc/init.d/apache2restartApache will create a new directory during installation:/var/www, which is the root directory where the document is stored on this server. All documents

PHP page Encoding declaration method header or Meta code

Header ("content-type:text/html; Charset=utf-8 "); Copy CodePHP page is GBK encoded Header ("content-type:text/html; charset=gb2312 "); Copy CodePHP page is BIG5 encoded

PHP Server Environment configuration (Apache and IIS two methods)

Default_charset= "gb2312", modify the default character set, here, if preceded by a semicolon ";", remove the semicolon; The Register_globals=off is changed to Register_globals=on, making the transitive global variable valid; Extension=

PHP character encoding conversion problem

$string =mb_convert_encoding ($string, character output encoding, original character encoding); Copy CodeFor example: Web pages use GBK encoding, strings are encoded using UTF-8, and characters are converted to Web page display

PHP Extract () function (array split) definition and usage

$a = ' Original '; $my _array = Array ("A" = "Cat", "b" = "Dog", "c" = "Horse"); Extract ($my _array); echo "\ $a = $a; \ $b = $b; \ $c = $c "; ?> Copy CodeOutput:$a = Cat; $b = Dog; $c = HorseExample 2 use all

PHP array Random Ordering example

$array = Array (' A ', ' 2 ', ' 3 ', ' 4 ', ' 5 ', ' 6 ', ' 7 ', ' 8 ', ' 9 ', ' Ten ', ' J ', ' Q ', ' K '); Shuffle ($array); Randomly sorted array Print_r ($array); Output array ?> Copy Code>>> you may be interested in the

PHP adds watermarks to png/jpg/gif format images

/** * Image plus watermark (for png/jpg/gif format) * * @author FLYNETCN * * @param $srcImg original picture * @param $waterImg watermark Picture * @param $savepath Save path * @param $savename Save name * @param

What are the functions of PHP MySQL escaping special characters?

This article introduces the functions of escaping special characters commonly used in PHP MySQL programming, including the use of mysql_escape_string and addslashes functions, as required by the friend reference. PHP MySQL escape function

PHP character escaping function reference

if (Phpversion () Set_magic_quotes_runtime (0); } Copy Code>> cannot define MAGIC_QUOTES_GPC through functions, so it is recommended to open the server uniformly, when writing the program should be judged, to avoid the

PHP Singleton mode (Singleton pattern) tutorial

dsn

Class DatabaseConnection { private static $db; private static $_handle = null; public static function get () { if (self:: $db = = null) { Echo __line__; Self:: $db = new DatabaseConnection ();

PHP Server Environment Build and Oracle Support

RPM-IVH http://nginx.org/packages/centos/6/noarch/rpms/nginx-release-centos-6-0.el6.ngx.noarch.rpm Copy CodeTo install the Epel source: (64-bit system) RPM-IVH

Basic knowledge Sharing: Php Basics Learn

What is PHP?PHP is an abbreviation for hypertextpreprocessor, and the PHP scripting language is an embedded HTML. PHP syntax is a unique mix of the C, Java, Perl, and PHP types of the new syntax. The purpose of this language is to allow web

How PHP automatically compensates for numbers or string digits

Generate 4 digits, less than 0 of the preceding $var =sprintf ("%04d", 2); echo $var;//result is 0002 echo Date (' Y_m_d ', Time ()). ' _ '. sprintf (' d ', rand (0,99)); ?> Copy CodeThe sprintf ()

PHP Server Configuration (Php+mysql+iis) steps

This article introduced the PHP server configuration detailed steps, the environment for Php+mysql+iis, grasp the PHP environment to build the method, the need for a friend reference.This section: How to build a PHP server environment.Software

What are the PHP5.3 and 5.5 deprecation and expiration functions?

This article describes some of the deprecated and outdated functions in PHP5.3 and 5.5, and everyone who is interested in using PHP functions as a reference. Added a new error level deprecated from PHP5.3, which is about to be

The difference analysis between PHP function Addslashes and mysql_real_escape_string

CREATE TABLE Users ( Username VARCHAR (+) CHARACTER SET GBK, Password VARCHAR (+) CHARACTER SET GBK, PRIMARY KEY (username) ); Copy Codeexample, simulates the case where the query data is escaped using only

Total Pages: 5208 1 .... 2031 2032 2033 2034 2035 .... 5208 Go to: GO

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.