005 php字串中的處理函式(四)

2021-09-07 15:39:09 字數 1228 閱讀 1935

<?php

/** * 字串處理函式:

* parse_url 解析url。返回其組成部分

*//*

$url="";

$arr=parse_url($url);

print_r($arr);//輸出:array ( [scheme] => http [host] => www.lan********.com [path] => /admin/index.php [query] => name=chen&a=add )

echo "

".parse_url($url,php_url_scheme);//輸出:http

echo "

".parse_url($url,php_url_host);//輸出:www.lan********.com

echo "

".parse_url($url,php_url_path);//輸出:/admin/index.php

echo "

".parse_url($url,php_url_query);//輸出:name=chen&a=add

*//*urlencode() url編碼:

*urldecode() 解碼,已編碼的內容

* \*/

/*echo "藍天網";

*//*

echo urlencode($str2);

echo "

";echo urldecode(urlencode($str2));

*//*htmlentities()講字串轉化為html實體。1.引數:操作內容,

2:轉換規則: ent_compat(轉換雙引號)

ent_quotes(轉換單雙引號) ent_noquotes(不轉換任何引號)

* * */

/*$str4='';

echo $str4;

echo htmlentities($str4);

$str4='"php div"';

echo htmlentities($str4);//轉換的字元裡面雙引號也被轉換

*//*

htmlspecialchars(); //不轉換中文;

*//*

$str4='"中國"';

echo htmlspecialchars($str4);//輸出:"中國"

*/echo $_get['uname'];

?>

php 中字串處理函式

1 查詢字元位置函式 strpos str,search,int 查詢search在 str中的第一次位置從int開始 stripos str,search,int 函式返回字串在另乙個字串中第一次出現的位置。該函式對大小寫不敏感 strrpos str,search,int 查詢search在 s...

php字串處理函式

addslashes 字串加入斜線。bin2hex 二進位轉成十六進製。chop 去除連續空白。chr 返回序數值的字元。chunk split 將字串分成小段。convert cyr string 轉換古斯拉夫字串成其它字串。crypt 將字串用 des 編碼加密。echo 輸出字串。explod...

php字串處理函式

echo 輸出乙個或多個字串 print 輸出乙個字串 printf 輸出格式化字串 trim 去除字串 首尾 空白等特殊符號或指定字串行 ltrim 去除字串 首 空白等特殊符號或指定字串行 rtrim 去除字串 尾 空白等特殊符號或指定字串行 chop 同 rtrim implode 使用字元將...