PHP learns scattered notes-string splits, fetch functions, and single double quotes. , fetch double quotes _php Tutorial

Source: Internet
Author: User
Tags php and mysql posix

PHP learns scattered notes-string splits, fetch functions, and single double quotes. , Fetch double Quotes


1 string splitting--split () function and Preg_split () function

Split-using regular expressions to split strings into arrays--seemingly PHP5.3 above deprecated
Array split (string $pattern, string $string [, int $limit])

Preg_split-separating strings by a regular expression

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

The same point: both use regular expressions to split the string.
Split () is simpler to use, such as splitting "2008-12-16 15:48:12", where split can write split (['-: ']).
and Preg_split () to be more complicated, you have to write Preg_split ("/[\s-:]/")
The reason: Split () only supports POSIX-style regular expressions, while Preg_split only supports Perl-style regular expressions
POSIX style is simpler than Perl style, but it's not binary safe

Yes, there is a explode (), which, unlike the above two functions, uses a string to divide the string.

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

Use one string to split another string

Note: There are a lot of binary security explanations on the Internet, and I feel that the following explanation is helpful in understanding the above sentence:

Binary security functions only care about binary strings, do not care about the specific format of the string, it only strictly in accordance with the binary data access, will not be in a special format to parse the data.

2 The difference between Mysqli::fetch_array and Mysqli::fetch_row

Mysqli_result::fetch_row ()

Get a row from the result set as an enumerated array

Mixed Mysqli_result::fetch_array ([int $resulttype = Mysqli_both])

Gets a row from the result set as an associative array, or as a numeric array, or both

The manual says the performance doesn't seem to be much different, the former is an enhanced version of the latter.

3 single and double quotation marks
PHP has two types of strings, single and double quotes.
A single quoted string is plain text (real text), which is sent directly to the browser without modification, whether it is a variable name or any other text.
Double-quoted string, PHP tries to calculate the double-quote string, where the variable name is replaced by the value of the variable.
Here, the concept of variables, strings, text, and raw data cannot be confused:
A variable is a symbol that represents data, a variable is represented by a variable name, a symbol that represents the data
and the single-quote string is the text, itself (literal) is the original data
The key is to understand the difference between text and variables, text is data, variables are symbols of data.

You can look at the introduction of the string in the 12th page of the Chinese version of PHP and MySQL Web development (Original book 4th edition).

Reference:

"PHP and MySQL Web development (Original book 4th edition)" Chinese version 12th page, Luke Welling & Laura Thomson

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

Know: What does binary security mean? http://www.zhihu.com/question/28705562

http://www.bkjia.com/PHPjc/1073811.html www.bkjia.com true http://www.bkjia.com/PHPjc/1073811.html techarticle PHP learns scattered notes-string splits, fetch functions, and single double quotes. , fetch double quotes 1 string split split () function and Preg_split () function split use regular expressions to split the string ...

  • 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.