
批改狀態(tài):合格
老師批語:
$hello = "Hello World";
$trimmed = ltrim($hello, "Hdle");
var_dump($trimmed);
2.str_shuffle — 隨機(jī)打亂一個(gè)字符串
str_shuffle(字符串) : string
$str = 'abcdef';
$shuffled = str_shuffle($str);
echo $shuffled;
3.strlen — 獲取字符串長(zhǎng)度
strlen( string $string) : int
$str = 'abcdef';
echo strlen($str);
4.strrev — 反轉(zhuǎn)字符串
strrev( string $string) : stringecho strrev("Hello world!");
5.str_repeat — 重復(fù)一個(gè)字符串
str_repeat( string $input, int $multiplier) : stringecho str_repeat("-=", 10);
6.addcslashes — 以 C 語言風(fēng)格使用反斜線轉(zhuǎn)義字符串中的字符
addcslashes(要轉(zhuǎn)義的字符串,轉(zhuǎn)義字符的范圍) : stringecho addcslashes('foo[ ]', 'A..z');
7.addslashes — 使用反斜線引用字符串
addslashes( string $str) : string
$str = "Is your name O'reilly?";
echo addslashes($str);
8.rtrim — 刪除字符串末端的空白字符(或者其他字符)
//rtrim( string $str, string $character_mask = ?) : string
$trimmed = rtrim($hello, "Hdle");
9.strip_tags — 從字符串中去除 HTML 和 PHP 標(biāo)記
strip_tags( string $str,指定不被去除的字符列表) : string
10.strtolower — 將字符串轉(zhuǎn)化為小寫
//strtolower( string $string) : string
$str = "Mary Had A Little Lamb and She LOVED It So";
$str = strtolower($str);
11.strtoupper — 將字符串轉(zhuǎn)化為大寫
// strtoupper( string $string) : string
$str = "Mary Had A Little Lamb and She LOVED It So";
$str = strtoupper($str);
// 12.trim — 去除字符串首尾處的空白字符(或者其他字符)
$hello = " Hello Worl ";
trim($hello, "Hdle");
var_dump($trimmed);
13.ucfirst — 將字符串的首字母轉(zhuǎn)換為大寫
$foo = 'hello world!';
$foo = ucfirst($foo);
14.ucwords — 將字符串中每個(gè)單詞的首字母轉(zhuǎn)換為大寫
//ucwords( string $str, string $delimiters = " \t\r\n\f\v" ) : string
$foo = 'hello world!';
$foo = ucwords($foo);
15.ucfirst — 將字符串的首字母轉(zhuǎn)換為大寫
將 str 的首字符(如果首字符是字母)轉(zhuǎn)換為大寫字母,并返回這個(gè)字符串。
$foo = 'hello world!';
$foo = ucfirst($foo);
16.strtolower — 將字符串轉(zhuǎn)化為小寫
// 將 string 中所有的字母字符轉(zhuǎn)換為小寫并返回。
$str = "Mary Had A Little Lamb and She LOVED It So";
$str = strtolower($str);
17.strtoupper — 將字符串轉(zhuǎn)化為大寫
//將 string 中所有的字母字符轉(zhuǎn)換為大寫并返回
$str = "Mary Had A Little Lamb and She LOVED It So";
$str = strtoupper($str);
18 lcfirst — 使一個(gè)字符串的第一個(gè)字符小寫
// 返回第一個(gè)字母小寫的 str ,如果是字母的話
$foo = 'HelloWorld';
$foo = lcfirst($foo);
19 htmlspecialchars — 將特殊字符轉(zhuǎn)換為 HTML 實(shí)體
$new = htmlspecialchars("<a href='test'>Test</a>", ENT_QUOTES);
echo $new;
20 strcmp — 二進(jìn)制安全字符串比較
//strcmp( string $str1, string $str2) : int
//如果 str1 小于 str2 返回 < 0;如果 str1 大于 str2 返回 > 0;如果兩者相等,返回 0。
$var1 = "Hello";
$var2 = "hello";
if (strcmp($var1, $var2) !== 0) {
echo '$var1 is not equal to $var2 in a case sensitive string comparison';
}
微信掃碼
關(guān)注PHP中文網(wǎng)服務(wù)號(hào)
QQ掃碼
加入技術(shù)交流群
Copyright 2014-2025 http://ipnx.cn/ All Rights Reserved | php.cn | 湘ICP備2023035733號(hào)