PHP中的字符串處理函數(shù)(String Functions) 全總結(jié)
Jun 13, 2016 am 09:36 AMphp 字符串處理函數(shù)大總結(jié),這些都是系統(tǒng)自帶的php字符串處理函數(shù)。
addcslashes — 為字符串里面的部分字符添加反斜線轉(zhuǎn)義字符
addslashes — 用指定的方式對(duì)字符串里面的字符進(jìn)行轉(zhuǎn)義
bin2hex — 將二進(jìn)制數(shù)據(jù)轉(zhuǎn)換成十六進(jìn)制表示
chop — rtrim() 的別名函數(shù)
chr — 返回一個(gè)字符的ASCII碼
chunk_split — 按一定的字符長(zhǎng)度將字符串分割成小塊
convert_cyr_string — 將斯拉夫語(yǔ)字符轉(zhuǎn)換為別的字符
convert_uudecode — 解密一個(gè)字符串
convert_uuencode — 加密一個(gè)字符串
count_chars — 返回一個(gè)字符串里面的字符使用信息
crc32 — 計(jì)算一個(gè)字符串的crc32多項(xiàng)式
crypt — 單向散列加密函數(shù)
echo — 用以顯示一些內(nèi)容
explode — 將一個(gè)字符串用分割符轉(zhuǎn)變?yōu)橐粩?shù)組形式
fprintf — 按照要求對(duì)數(shù)據(jù)進(jìn)行返回,并直接寫入文檔流
get_html_translation_table — 返回可以轉(zhuǎn)換的HTML實(shí)體
hebrev — 將Hebrew編碼的字符串轉(zhuǎn)換為可視的文本
hebrevc — 將Hebrew編碼的字符串轉(zhuǎn)換為可視的文本
html_entity_decode — htmlentities ()函數(shù)的反函數(shù),將HTML實(shí)體轉(zhuǎn)換為字符
htmlentities — 將字符串中一些字符轉(zhuǎn)換為HTML實(shí)體
htmlspecialchars_decode — htmlspecialchars()函數(shù)的反函數(shù),將HTML實(shí)體轉(zhuǎn)換為字符
htmlspecialchars — 將字符串中一些字符轉(zhuǎn)換為HTML實(shí)體
implode — 將數(shù)組用特定的分割符轉(zhuǎn)變?yōu)樽址?br>
join — 將數(shù)組轉(zhuǎn)變?yōu)樽址?,implode()函數(shù)的別名
levenshtein — 計(jì)算兩個(gè)詞的差別大小
localeconv — 獲取數(shù)字相關(guān)的格式定義
ltrim — 去除字符串左側(cè)的空白或者指定的字符
md5_file — 將一個(gè)文件進(jìn)行MD5算法加密
md5 — 將一個(gè)字符串進(jìn)行MD5算法加密
metaphone — 判斷一個(gè)字符串的發(fā)音規(guī)則
money_format — 按照參數(shù)對(duì)數(shù)字進(jìn)行格式化的輸出
nl_langinfo — 查詢語(yǔ)言和本地信息
nl2br — 將字符串中的換行符“/n”替換成“
”
number_format — 按照參數(shù)對(duì)數(shù)字進(jìn)行格式化的輸出
ord — 將一個(gè)ASCII碼轉(zhuǎn)換為一個(gè)字符
parse_str — 把一定格式的字符串轉(zhuǎn)變?yōu)樽兞亢椭?br>
print — 用以輸出一個(gè)單獨(dú)的值
printf — 按照要求對(duì)數(shù)據(jù)進(jìn)行顯示
quoted_printable_decode — 將一個(gè)字符串加密為一個(gè)8位的二進(jìn)制字符串
quotemeta — 對(duì)若干個(gè)特定字符進(jìn)行轉(zhuǎn)義
rtrim — 去除字符串右側(cè)的空白或者指定的字符
setlocale — 設(shè)置關(guān)于數(shù)字,日期等等的本地格式
sha1_file — 將一個(gè)文件進(jìn)行SHA1算法加密
sha1 — 將一個(gè)字符串進(jìn)行SHA1算法加密
similar_text — 比較兩個(gè)字符串,返回系統(tǒng)認(rèn)為的相似字符個(gè)數(shù)
soundex — 判斷一個(gè)字符串的發(fā)音規(guī)則
sprintf — 按照要求對(duì)數(shù)據(jù)進(jìn)行返回,但是不輸出
sscanf — 可以對(duì)字符串進(jìn)行格式化
str_ireplace — 像str_replace()函數(shù)一樣匹配和替換字符串,但是不區(qū)分大小寫
str_pad — 對(duì)字符串進(jìn)行兩側(cè)的補(bǔ)白
str_repeat — 對(duì)字符串進(jìn)行重復(fù)組合
str_replace — 匹配和替換字符串
str_rot13 — 將字符串進(jìn)行ROT13加密處理
str_shuffle — 對(duì)一個(gè)字符串里面的字符進(jìn)行隨機(jī)排序
str_split — 將一個(gè)字符串按照字符間距分割為一個(gè)數(shù)組
str_word_count — 獲取字符串里面的英文單詞信息
strcasecmp — 對(duì)字符串進(jìn)行大小比較,不區(qū)分大小寫
strchr — 通過(guò)比較返回一個(gè)字符串的部分strstr()函數(shù)的別名
strcmp — 對(duì)字符串進(jìn)行大小比較
strcoll – 根據(jù)本地設(shè)置對(duì)字符串進(jìn)行大小比較
strcspn — 返回字符連續(xù)非匹配長(zhǎng)度的值
strip_tags — 去除一個(gè)字符串里面的HTML和PHP代碼
stripcslashes — 反轉(zhuǎn)義addcslashes()函數(shù)轉(zhuǎn)義處理過(guò)的字符串
stripos — 查找并返回首個(gè)匹配項(xiàng)的位置,匹配不區(qū)分大小寫
stripslashes — 反轉(zhuǎn)義addslashes()函數(shù)轉(zhuǎn)義處理過(guò)的字符串
stristr — 通過(guò)比較返回一個(gè)字符串的部分,比較時(shí)不區(qū)分大小寫
strlen — 獲取一個(gè)字符串的編碼長(zhǎng)度
strnatcasecmp — 使用自然排序法對(duì)字符串進(jìn)行大小比較,不區(qū)分大小寫
strnatcmp — 使用自然排序法對(duì)字符串進(jìn)行大小比較
strncasecmp — 對(duì)字符串的前N個(gè)字符進(jìn)行大小比較,不區(qū)分大小寫
strncmp — 對(duì)字符串的前N個(gè)字符進(jìn)行大小比較
strpbrk — 通過(guò)比較返回一個(gè)字符串的部分
strpos — 查找并返回首個(gè)匹配項(xiàng)的位置
strrchr — 通過(guò)從后往前比較返回一個(gè)字符串的部分
strrev — 將字符串里面的所有字母反向排列
strripos — 從后往前查找并返回首個(gè)匹配項(xiàng)的位置,匹配不區(qū)分大小寫
strrpos – 從后往前查找并返回首個(gè)匹配項(xiàng)的位置
strspn — 匹配并返回字符連續(xù)出現(xiàn)長(zhǎng)度的值
strstr — 通過(guò)比較返回一個(gè)字符串的部分
strtok — 用指定的若干個(gè)字符來(lái)分割字符串
strtolower — 將字符串轉(zhuǎn)變?yōu)樾?br>
strtoupper –將字符串轉(zhuǎn)變?yōu)榇髮?br>
strtr — 對(duì)字符串比較替換
substr_compare — 對(duì)字符串進(jìn)行截取后的比較
substr_count — 計(jì)算字符串中某字符段的出現(xiàn)次數(shù)
substr_replace — 對(duì)字符串中的部分字符進(jìn)行替換
substr — 對(duì)字符串進(jìn)行截取
trim — 去除字符串兩邊的空白或者指定的字符
ucfirst — 將所給字符串的第一個(gè)字母轉(zhuǎn)換為大寫
ucwords — 將所給字符串的每一個(gè)英文單詞的第一個(gè)字母變成大寫
vfprintf — 按照要求對(duì)數(shù)據(jù)進(jìn)行返回,并直接寫入文檔流
vprintf — 按照要求對(duì)數(shù)據(jù)進(jìn)行顯示
vsprintf — 按照要求對(duì)數(shù)據(jù)進(jìn)行返回,但是不輸出
wordwrap — 按照一定的字符長(zhǎng)度分割字符串
您可能感興趣的文章
- php被遺忘的一些功能強(qiáng)大的字符串處理函數(shù)
- PHP 字符串轉(zhuǎn)義函數(shù)(addslashes,stripslashes)詳解
- php字符串替換函數(shù)str_replace速度比preg_replace快
- javascript的字符串編碼函數(shù)escape,encodeURI,encodeURIComponent比較與分析
- PHP 生成連續(xù)的數(shù)字(字母)數(shù)組函數(shù)range()分析,PHP抽獎(jiǎng)程序函數(shù)
- php中在變量和函數(shù)前加static關(guān)鍵字之后的區(qū)別
- php最精確的字符串長(zhǎng)度截取函數(shù)
- PHP 利用 Curl Functions 實(shí)現(xiàn)多線程抓取網(wǎng)頁(yè)和下載文件

Hot AI Tools

Undress AI Tool
Undress images for free

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Clothoff.io
AI clothes remover

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

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

PHPhasthreecommentstyles://,#forsingle-lineand/.../formulti-line.Usecommentstoexplainwhycodeexists,notwhatitdoes.MarkTODO/FIXMEitemsanddisablecodetemporarilyduringdebugging.Avoidover-commentingsimplelogic.Writeconcise,grammaticallycorrectcommentsandu

The key steps to install PHP on Windows include: 1. Download the appropriate PHP version and decompress it. It is recommended to use ThreadSafe version with Apache or NonThreadSafe version with Nginx; 2. Configure the php.ini file and rename php.ini-development or php.ini-production to php.ini; 3. Add the PHP path to the system environment variable Path for command line use; 4. Test whether PHP is installed successfully, execute php-v through the command line and run the built-in server to test the parsing capabilities; 5. If you use Apache, you need to configure P in httpd.conf

The basic syntax of PHP includes four key points: 1. The PHP tag must be ended, and the use of complete tags is recommended; 2. Echo and print are commonly used for output content, among which echo supports multiple parameters and is more efficient; 3. The annotation methods include //, # and //, to improve code readability; 4. Each statement must end with a semicolon, and spaces and line breaks do not affect execution but affect readability. Mastering these basic rules can help write clear and stable PHP code.

How to start writing your first PHP script? First, set up the local development environment, install XAMPP/MAMP/LAMP, and use a text editor to understand the server's running principle. Secondly, create a file called hello.php, enter the basic code and run the test. Third, learn to use PHP and HTML to achieve dynamic content output. Finally, pay attention to common errors such as missing semicolons, citation issues, and file extension errors, and enable error reports for debugging.

PHPisaserver-sidescriptinglanguageusedforwebdevelopment,especiallyfordynamicwebsitesandCMSplatformslikeWordPress.Itrunsontheserver,processesdata,interactswithdatabases,andsendsHTMLtobrowsers.Commonusesincludeuserauthentication,e-commerceplatforms,for

The steps to install PHP8 on Ubuntu are: 1. Update the software package list; 2. Install PHP8 and basic components; 3. Check the version to confirm that the installation is successful; 4. Install additional modules as needed. Windows users can download and decompress the ZIP package, then modify the configuration file, enable extensions, and add the path to environment variables. macOS users recommend using Homebrew to install, and perform steps such as adding tap, installing PHP8, setting the default version and verifying the version. Although the installation methods are different under different systems, the process is clear, so you can choose the right method according to the purpose.

TohandlefileoperationsinPHP,useappropriatefunctionsandmodes.1.Toreadafile,usefile_get_contents()forsmallfilesorfgets()inaloopforline-by-lineprocessing.2.Towritetoafile,usefile_put_contents()forsimplewritesorappendingwiththeFILE_APPENDflag,orfwrite()w

The key to writing Python's ifelse statements is to understand the logical structure and details. 1. The infrastructure is to execute a piece of code if conditions are established, otherwise the else part is executed, else is optional; 2. Multi-condition judgment is implemented with elif, and it is executed sequentially and stopped once it is met; 3. Nested if is used for further subdivision judgment, it is recommended not to exceed two layers; 4. A ternary expression can be used to replace simple ifelse in a simple scenario. Only by paying attention to indentation, conditional order and logical integrity can we write clear and stable judgment codes.
