W3Cschool
恭喜您成為首批注冊用戶
獲得88經(jīng)驗值獎勵
CodeIgniter 提供了一系列兼容性函數(shù)可以讓你使用,它們只有在高版本的 PHP 中才有, 或者需要依賴其他的擴展才有。
由于是自己實現(xiàn)的,這些函數(shù)本身也可能有它自己的依賴性,但如果你的 PHP 中不提供這些函數(shù)時, 這些函數(shù)還是有用的。
注解
和 公用函數(shù) 一樣,兼容性函數(shù)也一直可以訪問,只要滿足了他們的依賴條件。
這幾個兼容性函數(shù)移植了 PHP 標準的 密碼哈希擴展 的實現(xiàn), 這些函數(shù)只有在 PHP 5.5 以后的版本中才有。
password_get_info($hash)
參數(shù):
返回: Information about the hashed password
返回類型: array
更多信息,請參考 PHP 手冊中的 password_get_info() 函數(shù)
password_hash($password, $algo[, $options = array()])
參數(shù):
返回: Hashed password or FALSE on failure
返回類型: string
更多信息,請參考 PHP 手冊中的 password_hash() 函數(shù)
注解
除非提供了你自己的有效鹽值,該函數(shù)會依賴于一個可用的 CSPRNG 源(密碼學(xué)安全的偽隨機數(shù)生成器), 下面列表中的每一個都可以滿足這點: - mcrypt_create_iv() with MCRYPT_DEV_URANDOM - openssl_random_pseudo_bytes() - /dev/arandom - /dev/urandom
password_needs_rehash()
參數(shù):
返回: TRUE if the hash should be rehashed to match the given algorithm and options, FALSE otherwise
返回類型: bool
更多信息,請參考 PHP 手冊中的 password_needs_rehash() 函數(shù)
password_verify($password, $hash)
參數(shù):
返回: TRUE if the password matches the hash, FALSE if not
返回類型: bool
更多信息,請參考 PHP 手冊中的 password_verify() 函數(shù)
兼容性函數(shù)移植了 hash_equals() 和 hash_pbkdf2() 的實現(xiàn), 這兩函數(shù)分別在 PHP 5.6 和 PHP 5.5 以后的版本中才有。
hash_equals($known_string, $user_string)
參數(shù):
返回: TRUE if the strings match, FALSE otherwise
返回類型: string
更多信息,請參考 PHP 手冊中的 hash_equals() 函數(shù)
hash_pbkdf2($algo, $password, $salt, $iterations[, $length = 0[, $raw_output = FALSE]])
參數(shù):
返回: Password-derived key or FALSE on failure
返回類型: string
更多信息,請參考 PHP 手冊中的 hash_pbkdf2() 函數(shù)
這一系列兼容性函數(shù)提供了對 PHP 的 多字節(jié)字符串擴展 的有限支持, 由于可選的解決方法有限,所以只有幾個函數(shù)是可用的。
注解
如果沒有指定字符集參數(shù),默認使用 $config['charset'] 配置。
重要
這個依賴是可選的,無論 iconv 擴展是否存在,這些函數(shù)都已經(jīng)定義了, 如果 iconv 擴展不可用,它們會降級到非多字節(jié)字符串的函數(shù)版本。重要
當設(shè)置了字符集時,該字符集必須被 iconv 支持,并且要設(shè)置成它可以識別的格式。注解
如果你需要判斷是否支持真正的多字節(jié)字符串擴展,可以使用 MB_ENABLED 常量。
mb_strlen($str[, $encoding = NULL])
參數(shù):
返回: Number of characters in the input string or FALSE on failure
返回類型: string
更多信息,請參考 PHP 手冊中的 mb_strlen() 函數(shù)
mb_strpos($haystack, $needle[, $offset = 0[, $encoding = NULL]])
參數(shù):
返回: Numeric character position of where $needle was found or FALSE if not found
返回類型: mixed
更多信息,請參考 PHP 手冊中的 mb_strpos() 函數(shù)
mb_substr($str, $start[, $length = NULL[, $encoding = NULL]])
參數(shù):
返回: Portion of $str specified by $start and $length or FALSE on failure
返回類型: string
更多信息,請參考 PHP 手冊中的 mb_substr() 函數(shù)
這一系列兼容性函數(shù)提供了一些高版本的 PHP 中才有的標準函數(shù)。
array_column(array $array, $column_key[, $index_key = NULL])
參數(shù):
返回: An array of values representing a single column from the input array
返回類型: array
更多信息,請參考 PHP 手冊中的 array_column() 函數(shù)
array_replace(array $array1[, ...])
參數(shù):
返回: Modified array
返回類型: array
更多信息,請參考 PHP 手冊中的 array_replace() 函數(shù)
array_replace_recursive(array $array1[, ...])
參數(shù):
返回: Modified array
返回類型: array
更多信息,請參考 PHP 手冊中的 array_replace_recursive() 函數(shù)
重要
只有 PHP 原生的函數(shù)才可以檢測到無窮遞歸,如果你使用的是 PHP 5.3+ ,使用時要擔心引用!hex2bin($data)
參數(shù):
返回: Binary representation of the given data
返回類型: string
更多信息,請參考 PHP 手冊中的 hex2bin() 函數(shù)
quoted_printable_encode($str)
參數(shù):
返回:
8bit-encoded string
返回類型: string
Copyright©2021 w3cschool編程獅|閩ICP備15016281號-3|閩公網(wǎng)安備35020302033924號
違法和不良信息舉報電話:173-0602-2364|舉報郵箱:jubao@eeedong.com
掃描二維碼
下載編程獅App
編程獅公眾號
聯(lián)系方式:
更多建議: