STEP 1: 請創建輔助文件夾中的輔助函數
function encode_url($string, $key="", $url_safe=TRUE)
{
if($key==null || $key=="")
{
$key="tyz_mydefaulturlencryption";
}
$CI =& get_instance();
$ret = $CI->encrypt->encode($string, $key);
if ($url_safe)
{
$ret = strtr(
$ret,
array(
'+' => '.',
'=' => '-',
'/' => '~'
)
);
}
return $ret;
}
function decode_url($string, $key="")
{
if($key==null || $key=="")
{
$key="tyz_mydefaulturlencryption";
}
$CI =& get_instance();
$string = strtr(
$string,
array(
'.' => '+',
'-' => '=',
'~' => '/'
)
);
return $CI->encrypt->decode($string, $key);
}
第2步:在自動載入文件中指定此文件
$autoload['helper'] = array('url','form','url_encryption_helper');
步驟3:在控制器,型號 呼叫功能encode_url
,鑑於加密
$rr="rahul K A";
$a= encode_url($rr);
爲什麼沒有人沒有做回答這個。 – user2743387
http://ellislab.com/codeigniter/user-guide/libraries/encryption.html 沒有幫助你嗎? –
不,plaese helpme – user2743387