Home php教程 php手册 PHP常用字符串的大集合

PHP常用字符串的大集合

Jun 13, 2016 am 11:06 AM
add php for introduce function big string Commonly used us yes of kind Convert gather

我们今天为大家介绍的是PHP常用字符串之字符串转换类函数 

addcslashes函数:以C语言风格使用反斜线转义字符串中的字符 

addslashes函数:使用反斜线引用字符串 

chop函数:清除字符串中的连续空格 

get_html_translation_table函数:返回htmlspecialchars()函数和htmlentities()函数的转换表 

chunk_split函数:将字符串分割成小块 

hebrev函数:转换希伯来逻辑字符为可见字符 

hebrevc函数:转换希伯来语文本为可见文本,包括换行符 

html_entity_decode函数:转换HTML字符编码为字符 

htmlentities函数:转换字符为HTML字符编码 

htmlspecialchars_decode函数:转换特殊HTML字符编码为字符 

htmlspecialchars函数:转换特殊字符为HTML字符编码

nl2br函数:将换行字符转换成“
” 

quotemeta函数:加入引用符 

rtrim函数:清除字符串末尾的空白(或其他字符) 

strip_tags函数:清除HTML及PHP的标记 

stripcslashes函数:将用addslashes()函数处理后的字符串原样返回 

stripslashes函数:清除字符串中的反斜线 

strtolower函数:将字符串中的字母全部转换为小写 

strtoupper函数:将字符串中的字母全部转换为大写 

trim函数:截取字符串首尾的空格(或其他字符)字符串操作类函数 

explode函数:将字符串按指定字符切开 

str_pad函数:用一个字符串填充另一个字符串到指定长度 

str_split函数:把字符串转化为数组 

str_shuffle函数:随机打乱字符串中的字符顺序 

str_ireplace函数:将某个子字符串替换为另一个字符串 

localeconv函数:获取当地的数字和货币信息 

ltrim函数:清除字符串左端的连续空白(或者其他字符) 

money_format函数:把数字字符串转换为货币表示形式 

nl_langinfo函数:获取语言和地区信息 

number_format函数:用千位分隔符格式化数字字符串 

parse_str函数:将字符串解析为变量 

setlocale函数:设置地区信息 

similar_text函数:计算两个字符串中相匹配的字符串数量 

str_repeat函数:重复使用指定字符串

str_replace函数:区分大小写的字符串替换 

str_word_count函数:返回字符串中的单词数 

strcasecmp函数:对两个字符串进行比较 

strlen函数:统计字符串的长度 

strnatcmp函数:使用自然顺序演算法来对比字符串 

strrev函数:颠倒字符串 

strtok函数:切开字符串 

strtr函数:转换字符串的某些字符 

substr_count函数:计算一个字符串在另一个字符串中出现的次数 

substr_replace函数:替换字符串中的一部分为另一个字符串 

substr函数:截取字符串 

ucfirst函数:将字符串中第一个字符改为大写 

ucwords函数:将字符串中每个单词的第一个字母改为大写 

wordwrap函数:将字符串按字符个数换行 

PHP常用字符串之字符串查找类函数 

chr函数:将指定的序数转化为相应的ASCII码字符 

implode函数:将数组合并为字符串 

join函数:将数组转化为字符串 

crc32函数:计算一个字符串的crc32多项式 

strchr函数:返回字符串在另一个字符串中首次出现的位置到末尾的子字符串 

strcspn函数:返回字符串中起首不符合mask的子字符串长度 

stripos函数:查找一个字符串在另一个字符串中首次出现的位置(不区分大小写)

stristr函数:返回一个字符串在另一个字符串中首次出现的位置到后者末尾的子字符串(不区分大小写)

strripos函数:不区分大小写查找字符在字符串中首次出现的位置 

strrpos函数:查找字符在字符串中最后出现的位置 

strspn函数:返回字符串中起首符合mask的子字符串长度 

strstr函数:返回字符串中某字符串开始处至结束的字符串 

PHP常用字符串之字符串编码类函数 

bin2hex函数:将二进制字符转化为十六进制 

convert_cyr_string函数:将字符由一种Cyrillic字符转换成另一种 

convert_uudecode函数:对用uuencode算法编码的字符串解码 

convert_uuencode函数:对字符串进行uuencode算法编码

count_chars函数:返回字符串中所有字符的信息

ord函数:返回一个字符的ASCII码 

str_rot13函数:对一个字符串进行rot13编码

PHP常用字符串之字符串加密类函数 

crypt函数:将字符串用DES编码加密 

md5_file函数:计算给定文件的MD5hash 

md5函数:对一个字符串进行MD5加密 

sha1_file函数:计算给定文件的sha1hash 

echo函数:输出一个或多个字符 

fprintf函数:输出格式化字符串到流 

print函数:输出格式化字符串 

printf函数:输出一个格式化的字符串 

sprintf函数:返回一个格式化的字符串到变量 

sscanf函数:按照一定格式解析输入的字符串 

vfprintf函数:输出格式化字符串到流 

vprintf函数:输出一个格式化的字符串 

vsprintf函数:输出格式化的字符串到变量 

PHP常用字符串之字符串比较类函数 

levenshtein函数:计算两个字符串的Levenshtein距离 

metaphone函数:计算字符串的metaphone键 

soundex函数:计算字符串的soundex键 

strcoll函数:对两个字符串进行比较 

strcmp函数:比较两个字符串 

strnatcasecmp函数:用自然运算法则比较字符串(不区分大小写) 

strncasecmp函数:比较字符串的前n个字符(不区分大小写)

strncmp函数:比较两个字符串的前n个字符

strpbrk函数:查找字符串中的一系列字符

strpos函数:寻找字符串中某字符最先出现的位置

strrchr函数:查找一个字符串在另一个字符串中末次出现的位置,并返回从字符串中的这个位置起,一直到字符串结尾的子字符串

substr_compare函数:从指定起始位置起在一定长度内比较两个字符串(二进制精确,区分大小写可选)


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

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.

Undress AI Tool

Undress AI Tool

Undress images for free

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)

PHP 8.4 Installation and Upgrade guide for Ubuntu and Debian PHP 8.4 Installation and Upgrade guide for Ubuntu and Debian Dec 24, 2024 pm 04:42 PM

PHP 8.4 brings several new features, security improvements, and performance improvements with healthy amounts of feature deprecations and removals. This guide explains how to install PHP 8.4 or upgrade to PHP 8.4 on Ubuntu, Debian, or their derivati

How To Set Up Visual Studio Code (VS Code) for PHP Development How To Set Up Visual Studio Code (VS Code) for PHP Development Dec 20, 2024 am 11:31 AM

Visual Studio Code, also known as VS Code, is a free source code editor — or integrated development environment (IDE) — available for all major operating systems. With a large collection of extensions for many programming languages, VS Code can be c

Explain JSON Web Tokens (JWT) and their use case in PHP APIs. Explain JSON Web Tokens (JWT) and their use case in PHP APIs. Apr 05, 2025 am 12:04 AM

JWT is an open standard based on JSON, used to securely transmit information between parties, mainly for identity authentication and information exchange. 1. JWT consists of three parts: Header, Payload and Signature. 2. The working principle of JWT includes three steps: generating JWT, verifying JWT and parsing Payload. 3. When using JWT for authentication in PHP, JWT can be generated and verified, and user role and permission information can be included in advanced usage. 4. Common errors include signature verification failure, token expiration, and payload oversized. Debugging skills include using debugging tools and logging. 5. Performance optimization and best practices include using appropriate signature algorithms, setting validity periods reasonably,

PHP Program to Count Vowels in a String PHP Program to Count Vowels in a String Feb 07, 2025 pm 12:12 PM

A string is a sequence of characters, including letters, numbers, and symbols. This tutorial will learn how to calculate the number of vowels in a given string in PHP using different methods. The vowels in English are a, e, i, o, u, and they can be uppercase or lowercase. What is a vowel? Vowels are alphabetic characters that represent a specific pronunciation. There are five vowels in English, including uppercase and lowercase: a, e, i, o, u Example 1 Input: String = "Tutorialspoint" Output: 6 explain The vowels in the string "Tutorialspoint" are u, o, i, a, o, i. There are 6 yuan in total

How do you parse and process HTML/XML in PHP? How do you parse and process HTML/XML in PHP? Feb 07, 2025 am 11:57 AM

This tutorial demonstrates how to efficiently process XML documents using PHP. XML (eXtensible Markup Language) is a versatile text-based markup language designed for both human readability and machine parsing. It's commonly used for data storage an

Explain late static binding in PHP (static::). Explain late static binding in PHP (static::). Apr 03, 2025 am 12:04 AM

Static binding (static::) implements late static binding (LSB) in PHP, allowing calling classes to be referenced in static contexts rather than defining classes. 1) The parsing process is performed at runtime, 2) Look up the call class in the inheritance relationship, 3) It may bring performance overhead.

What are PHP magic methods (__construct, __destruct, __call, __get, __set, etc.) and provide use cases? What are PHP magic methods (__construct, __destruct, __call, __get, __set, etc.) and provide use cases? Apr 03, 2025 am 12:03 AM

What are the magic methods of PHP? PHP's magic methods include: 1.\_\_construct, used to initialize objects; 2.\_\_destruct, used to clean up resources; 3.\_\_call, handle non-existent method calls; 4.\_\_get, implement dynamic attribute access; 5.\_\_set, implement dynamic attribute settings. These methods are automatically called in certain situations, improving code flexibility and efficiency.

PHP and Python: Comparing Two Popular Programming Languages PHP and Python: Comparing Two Popular Programming Languages Apr 14, 2025 am 12:13 AM

PHP and Python each have their own advantages, and choose according to project requirements. 1.PHP is suitable for web development, especially for rapid development and maintenance of websites. 2. Python is suitable for data science, machine learning and artificial intelligence, with concise syntax and suitable for beginners.

See all articles