PHP- common function [] - commonly used functions

Learning Points

  1. URL encoding and decoding urlencode urldecode
  2. Strlen strlen string length when computing a UTF8 treat Chinese character length is 3
  3. count function: the length of the array of statistics
  4. md5 and sha256 string data md5
  5. ksort: alphabetical order of the array of key values
  6. base64_decode
  7. 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);
?>

 

Published 47 original articles · won praise 3 · Views 1952

Guess you like

Origin blog.csdn.net/yueyekonglong/article/details/104025169