Php learning discrete notes-string segmentation, fetch functions, and single double quotation marks.

Source: Internet
Author: User
: This article mainly introduces the scattered notes of php learning-string segmentation, fetch function and single double quotation marks ., If you are interested in the PHP Tutorial, refer. 1 string segmentation -- split () and preg_split () functions

Split-useRegular expressionSplits the string into an array. it seems that PHP5.3 and above are not supported.
Array split (string $ pattern, string $ string [, int $ limit])

Preg_split-useRegular expressionSeparator string

Array preg_split (string $ pattern, string $ subject [, int $ limit =-1 [, int $ flags = 0])

Similarities: both useRegular expressionTo split the string.
Split () is easier to use. for example, to split "15:48:12", split can be written like this (['-:']).
To make preg_split () more complex, you have to write preg_split ("/[\ s-:]/").
The reason is: split () only supports POSIX styleRegular expressionAnd preg_split only supports Perl-styleRegular expression
POSIX is simpler than Perl, but it is not binary secure

By the way, there is an explode (), which is different from the above two functions. it uses strings to separate strings.

Array explode (string $ delimiter, string $ string [, int $ limit])

Use one string to separate another string

Note: There are many binary security explanations on the internet. I feel that the following explanation is helpful for understanding the above sentence:

Binary security functions only focus on binary strings and do not care about the specific format of strings. they only strictly access binary data and do not parse data in a special format.

2 What is the difference between mysqli: fetch_array and mysqli: fetch_row?

Mysqli_result: fetch_row ()

Retrieve a row from the result set as an enumerated array

Mixed mysqli_result: fetch_array ([int $ resulttype = MYSQLI_BOTH])

Get a row from the result set as an associated array or number array, or both

The manual says there seems to be no major difference between the two. The former is the enhanced version of the latter.

3 Single quotes and double quotes
Php two string types, single quotes and double quotation marks.
The single quotation mark string is a plain text (real text), which is directly sent to the browser without modification, whether it is a variable name or any other text.
Double quotation mark string. php will try to calculate the double quotation mark string, and the variable name will be replaced by the variable value.
Here, the concepts of variables, strings, text, and raw data cannot be confused:
A variable is a data symbol. a variable is represented by a variable name, indicating a data symbol.
The single quotation mark string is text, and itself (the literal value) is the original data.
The key is to understand the differences between text and variables. text is data, and variables are data symbols.

Let's take a look at the introduction of strings on the 4th page of the Chinese version of PHP and MySQL Web Development (formerly known as MySQL 12th.

Refer:

Page 4th of the Chinese version of PHP and MySQL Web Development (formerly known as MySQL 12th), by Luke Welling & Laura Thomson

Php binary string meaning http://www.lofter.com/postentry? From = search & permalink = 139418_34c583

Zhihu: What does binary security mean? Http://www.zhihu.com/question/28705562

The preceding section describes the character string splitting, fetch function, and single double quotation marks in php ., Including the regular expression content, hope to be helpful to friends who are interested in PHP tutorials.

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.