Learning Points
- URL encoding and decoding urlencode urldecode
- Strlen strlen string length when computing a UTF8 treat Chinese character length is 3
- count function: the length of the array of statistics
- md5 and sha256 string data md5
- ksort: alphabetical order of the array of key values
- base64_decode
- pathinfo
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<?php
//URL的编码解码
$var1="中国人ホーム";
echo urlencode($var1);
echo "<br />";
echo urldecode(urlencode($var1));
echo "<hr />";
//获取字符串的长度
echo strlen($var1);//18 在strlen计算时,对待一个UTF8的中文字符是3个长度
echo "<br />";
echo strlen("Hello world!");//12
echo "<br />";
echo "<hr />";
//md5 and sha256
echo hash("md5",$var1);
echo "<br />";
echo hash("sha256",$var1);
echo "<hr />";
//count
$returnData = array(
'transType' => 'sales',
'orderNo' => '201510198033887',
'merNo' => '968',
'terNo' => '88816',
'currencyCode' => 'USD',
'amount' => '98.14',
'tradeNo' => 'HP1510190848271792',
'respCode' => '00',
'respMsg' => '00:success'
);
print_r(count($returnData));
echo "<hr />";
ksort($returnData);
print_r($returnData);
?>