国产av日韩一区二区三区精品,成人性爱视频在线观看,国产,欧美,日韩,一区,www.成色av久久成人,2222eeee成人天堂

Table of Contents
php學習零散筆記—字符串分割、fetch函數(shù)和單雙引號。,fetch雙引號
Home php教程 php手冊 php學習零散筆記—字符串分割、fetch函數(shù)和單雙引號。,fetch雙引號

php學習零散筆記—字符串分割、fetch函數(shù)和單雙引號。,fetch雙引號

Jun 13, 2016 am 08:50 AM
apostrophe

php學習零散筆記—字符串分割、fetch函數(shù)和單雙引號。,fetch雙引號

1 字符串分割——split()函數(shù)和preg_split()函數(shù)

split — 用正則表達式將字符串分割到數(shù)組中——貌似PHP5.3以上已不贊成使用
array split ( string $pattern , string $string [, int $limit ] )

preg_split —?通過一個正則表達式分隔字符串

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

相同點:都是用正則表達式來分割字符串。
split()用起來更簡單,比如分割"2008-12-16 15:48:12",split可以這么寫split(['- :'])
而preg_split()要復雜些,就得這么寫preg_split("/[\s-:]/")
原因是:split()只支持POSIX風格的正則表達式,而preg_split只支持Perl風格的正則表達式
POSIX風格要比Perl風格的簡單,但它不是二進制安全的

對了,還有個explode(),和上面兩個函數(shù)不同,它是用字符串來分割字符串。

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

使用一個字符串分割另一個字符串

注:網(wǎng)上有好多二進制安全的解釋,我感覺下面這個解釋對于理解上面那句話有幫助:

二進制安全的函數(shù)只關心二進制化的字符串,不關心字符串的具體格式,它只會嚴格的按照二進制的數(shù)據(jù)進行存取,不會以某種特殊格式解析數(shù)據(jù)。

2 mysqli::fetch_array 和mysqli::fetch_row的區(qū)別

?mysqli_result::fetch_row()?

從結果集中取得一行作為枚舉數(shù)組

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

從結果集中取得一行作為關聯(lián)數(shù)組,或數(shù)字數(shù)組,或二者兼有

手冊說兩者性能貌似沒有太大的區(qū)別,前者是后者的增強版。

3 單引號和雙引號
php的兩種字符串類型,單引號和雙引號。
單引號的字符串是純文本(真正的文本),它會不經(jīng)修改而直接發(fā)送給瀏覽器,不管是變量名稱還是其它任何文本。
雙引號的字符串,php會嘗試計算雙引號字符串,其中的變量名稱將被變量值所代替。
在這里,變量、字符串、文本和原始數(shù)據(jù)的概念不能混淆:
變量是表示數(shù)據(jù)的符號,變量用變量名稱表示,表示數(shù)據(jù)的符號
而單引號的字符串則是文本,本身(字面值)就是原始數(shù)據(jù)
關鍵是理解文本和變量的區(qū)別,文本是數(shù)據(jù),變量是數(shù)據(jù)的符號。

可以看看《PHP和MySQL Web開發(fā)(原書第4版)》中文版第12頁對于字符串的介紹。

參考:

《PHP和MySQL Web開發(fā)(原書第4版)》中文版第12頁,Luke Welling & Laura Thomson著

php二進制字符串的含義?http://www.lofter.com/postentry?from=search&permalink=139418_34c583

知乎:二進制安全是什么意思? http://www.zhihu.com/question/28705562

Statement of this Website
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

Hot AI Tools

Undress AI Tool

Undress AI Tool

Undress images for free

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)