Home  >  Article  >  Backend Development  >  The use of strings in PHP programs

The use of strings in PHP programs

WBOY
WBOYOriginal
2016-07-29 09:11:53845browse

1. String declaration

(1) You can use single quotes and double quotes

Difference: Variables can be parsed in double quotes, and all escape characters can be used

(2) Use the delimiter << <

2. String processing

mainly uses strings for splitting, matching, searching, and replacing

3. String processing functions

Features:

1. If it is other types of data, also You can use the string processing function to process it. The processing process is to automatically convert other types of data into strings before processing.

Second, strings can be accessed through subscripts like arrays, but the type is not an array, but a string

Three, in addition to English, there are also Chinese strings (different encodings account for The number of bytes is different, UTF8 occupies 3 bytes)

(1) strlen("hello"); count the length of the string

(2) $str[0].$str[1]; access string $ The first and second elements of str are of type string. (You can also use {} to access subscripts)

The above introduces the use of strings in PHP programs, including aspects of content. I hope it will be helpful to friends who are interested in PHP tutorials.

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn