PHP 第五章 字串編碼函式

2021-09-08 13:19:01 字數 1146 閱讀 1526

<?php

header("content-type:text/html;charset=utf-8");

和base64_decode。64位編碼轉換。

/*$str='美麗中國';

echo base64_encode($str);

//輸出:576o5li95lit5zu9

echo base64_decode('576o5li95lit5zu9 ');

*///

輸出:美麗中國

生成url_encode請求字串。

輸出:z=zhong&g=guo&age=108

解析url字串。

/*$url="中國&school=dongli#abc";

print_r(parse_url($url));

*///

輸出:array ( [scheme] => http [host] => www.phpdl.com [path] => /index.php [query] => site=php中國&school=dongli [fragment] => abc )

編碼url字元。

/*$url="";

echo urlencode($url);

*///

輸出:http%3a%2f%2fwww.baidu.com

解碼已編碼的url字串。

輸出:

按照 rfc 1738 對 url 進行編碼

/*$str="";

echo rawurlencode($str);

*///

輸出:http%3a%2f%2fwww.baidu.com

對已編碼的 url 字串進行解碼

//輸出:

?>

PHP 第五章 字串的分割與替換

header content type text html charset utf 8 字串的擷取與分割 1.字串擷取類函式 1 trim去除字串手尾處的空白。例1 清理字串兩邊的字元 b trim php var dump b 輸出 string php length 3 例2 清除字串兩邊的空白...

第五章 函式

第五章 函式 1 函式的定義 shell函式定義可以放在 bash profile 檔案中,也可以在使用該函式的指令碼中,還可以在命令列中 通過 source 或 執行bash profile檔案,使修改能夠立即生效 function 函式名 declare f 顯示定義的函式清單 export f...

第五章 函式

在lua中,函式是對語句和表示式進行抽象的主要機制。即使呼叫函式時沒有引數,也必須要寫出一對空括號。一種特殊的例外情況 乙個函式若只有乙個引數,且此引數是乙個字面字串或table構造式,那麼圓括號別是可有可無的。print hello world dofile test.lua print a mu...