批改状态:合格
老师批语:
$str = 'title="hello world 123"';echo "$str<hr>";// 1. 使用反斜线引用字符串$test = addslashes($str);echo "$test<hr>";// 2. 反引用一个引用字符串 除反斜杠$test = stripslashes($test);echo "$test<hr>";// 3. 将特殊字符转换为 HTML 实体$test = htmlspecialchars($str);echo "$test<hr>";// 4.将特殊的 HTML 实体转换回普通字符$test = htmlspecialchars_decode($test);echo " $test<hr>";// 5. 转义元字符集$test = quotemeta($str);echo "$test<hr>";// 6. 传递给脚本的参数 数组格式输入解析$g = sscanf('hello world zsh', '%s %s %s', $h1, $w1,$z1);echo "$g : $h1 $w1 $z1<hr>";// 7. 随机打乱一个字符串echo str_shuffle($str);// 8.返回字符串中单词的使用情况$test = str_word_count($str);echo "$test<hr>";$test = str_word_count($str, 1);echo print_r($test, true), '<hr>';$test = str_word_count($str, 2);echo print_r($test, true), '<hr>';// 9. 输出或返回一个变量的字符串表示echo var_export(strcmp('13', 13) === 0, true), '<hr>';// 10. 字符串长度$test = strlen($str);echo "$test<hr>";// 11. 字符串反转$test = strrev($str);echo "$test<hr>";// 12. 标记分割字符串$test = strtok('ABCD.EFG', '.');echo "$test<hr>";// 13. 字符串转大写$test = strtoupper($str);echo "$test<hr>";// 14. 字符串转小写$test = strtolower($str);echo "$test<hr>";// 15. 转换指定字符到字符$test = strtr($str, array('world' => 'wyhtn'));echo "$test<hr>";// 16. 将字符串的首字母转换为大写echo ucfirst('hello email password <hr>');//17. 使一个字符串的第一个字符小写echo lcfirst("WESUUZ YMYWT MNYSQ!<hr>");// 将字符串中每个单词的首字母转换为大写echo ucwords('hello email password <hr>');// 18. 单词分割子串$test = wordwrap('hello email password',8, "<hr>");echo "$test<hr>";//19. parse_str 将字符串解析成多个变量parse_str("hello= email & password= 12345",$testw);print_r($testw);echo "<hr>";//20. chop — rtrim()的别名,删除字符串的最后一个字符$str = "hello email password";;echo $str . "<hr>";echo chop($str,"password<hr>");//21. 使用uuencode编码一个字符串$bianmazfc = convert_uuencode($str);echo $bianmazfc . "<br>";echo "<hr>";// 解码一个 uuencode 编码的字符串$bianmazfc = convert_uudecode($bianmazfc);echo $bianmazfc;


Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号