Tải bản đầy đủ (.pdf) (5 trang)

PHP Developer''''s Dictionary- P33 pptx

Bạn đang xem bản rút gọn của tài liệu. Xem và tải ngay bản đầy đủ của tài liệu tại đây (363.79 KB, 5 trang )

PHP Developer’s Dictionary
IT-SC book
160
Syntax

string chop(string str)


Description
The
chop()
function returns the str
parameter without any trailing whitespace.
Whitespace includes
"\\ n"
,
"\\ r"
,
"\\ t"
,
"\\ v"
,
"\\ 0"
, and a plain space.
chr()
Syntax

string chr(int ascii)


Description


The
chr()
function returns a one-character string that corresponds to the ASCII
code specified by the parameter.

echo chr(65);//displays A


chunk_split()
Syntax

string chunk_split(string string, int [chunklen] , string [end])


Description
The
chunk_split()
function, which was added in PHP 3.0.6 and PHP 4.0, returns
string broken up at every chunklen characters by the string end . The optional
parameter chunklen defaults to
76
, and
end
defaults to (
"\\ r\\ n"
). In other
words, the default behavior is to take a long string and break it into multiple lines of
length 76. This can be useful for converting base64-endcoded output to match RFC
2045 semantics. Base64 encoding is used to preserve binary data when transferring
it via electronic mail.

convert_cyr_string()
PHP Developer’s Dictionary
IT-SC book
161
Syntax

string convert_cyr_string(string str, string from, string to);


Description
The
convert_cyr_string()
function, which was added in PHP 3.0.6 and PHP 4.0,
returns str converted from one Cyrillic character set to another. The from and
to

parameters are single characters that represent Cyrillic character sets. The str
is the
character set to which it should be converted. The supported types of Cyrillic
character sets are
k—koi8-r
w
—Windows-1251
i
—ISO8859-5
a
—x-cp866
d
—x-cp866
m

—x-mac-cyrillic
count_chars()
Syntax

mixed count_chars(string string, [mode]);


Description
The
count_chars()
function, which was added in PHP 4.0, counts the number of
occurrences of each byte value (0–255) in string
and returns the information in a
format determined by mode
. If mode
is not specified, it defaults to
0
. The options for
mode
include:
0
—An array with the key representing the byte value and the value
representing the frequency of each byte.
1
—An array similar to
0
but only non-zero frequency byte values are
listed.
2
—An array similar to

0
but only zero frequency byte values are listed.
PHP Developer’s Dictionary
IT-SC book
162
3
—A string is returned containing only the byte values that are used.
4—A string is returned containing only the byte values that are not
used.
crc32()
Syntax

int crc32(string str)


Description
The
crc32()
function, which was added in PHP 4.0.1, calculates the crc32 polynomial
of the string . This is typically used to validate data that has been transmitted.
crypt()
Syntax

string crypt(string str, string [salt] )


Description
The
crypt()
function encrypts str using the standard UNIX DES encryption method.

The salt is an optional two-character parameter on which the encryption is based. If
salt is not provided, PHP will randomly generate one. For some operating systems,
an MD5-based encryption algorithm replaces the standard DES encryption. The
encryption type is specified by the salt
parameter. During installation of PHP, it is
determined which encryption functions are in use on the system. If salt is not
specified, PHP will auto-generate a salt based on the default encryption type for the
system. Either the standard 2-character DES salt or a random MD5-compatible salt is
generated. You can determine which encryption method is in use by examining the
constant
CRYPT_SALT_LENGTH
.
The output will contain the salt
as the first two numbers when using the standard
DES encryption
crypt()
function.
On systems where multiple encryption types are supported, the
crypt()
function
accepts either
0
or
1
, depending on whether the given type is available:
CRYPT_STD_DES—
Standard DES encryption with a 2-character salt

CRYPT_EXT_DES—
Extended DES encryption with a 9-char salt


PHP Developer’s Dictionary
IT-SC book
163
CRYPT_MD5—
MD5 encryption with a 12-char
salt
where the first
characters of the result are
$1$

CRYPT_BLOWFISH—Extended DES encryption with a 16-char
salt
where
the first characters of the result are $2$
Note that
crypt()
is a one-direction algorithm. The original str
cannot be
determined from the resulting string.
echo()
Syntax

echo(string arg1, string [argn]…)


Description
The
echo()
language construct outputs all the given parameters to the page.

Parentheses are optional with one argument and should not be used with multiple
arguments.

echo "Hello World!";// display Hello World message to user


explode()
Syntax

array explode(string separator, string string)


Description
The
explode()
function returns an array of strings where each element is from the
string parameter, which is broken out by the separator field.

$array1 = explode(",","1,2,3");//$array1 = (1,2,3)


flush()
Syntax

PHP Developer’s Dictionary
IT-SC book
164
void flush(void)



Description
The flush() function tries to force the current output to be returned to the user. The
actual results depend on the method PHP is using for delivery.
get_html_translation_table
Syntax

string get_html_translation_table(int table)


Description
The
get_html_translation_table()
function, which was added in PHP 4.0b4,
returns the translation table that is used internally for
htmlspecialchars()
and
htmlentities()
. You should use
HTML_ENTITIES
OR
HTML_SPECIALCHARS
to specify
which table you want.
get_meta_tags()
Syntax

array get_meta_tags(string filename, int [use_include_path] )


Description

The
get_meta_tags()
function, which was added in PHP 3.04 and PHP 4.0, opens a
file specified by
filename

and parses it looking for any
<meta>
HTML tags. In the
array that is returned, the name property of each meta tag becomes the key and the
contents of each meta tag becomes the value. If any special characters exist in the
value of the name property, they are substituted with
'_'
, and the rest of the value
is converted to lowercase. Specifying
use_include_path
as
1
asks PHP to look for
the file along the standard include path.
htmlentities()
Syntax

string htmlentities(string string)

×