PHP Conference Japan 2024

convert_uuencode

(PHP 5, PHP 7, PHP 8)

convert_uuencode使用 uuencode 編碼字串

說明

convert_uuencode(字串 $string): 字串

convert_uuencode() 使用 uuencode 演算法對字串進行編碼。

Uuencode 將所有字串(包括二進位資料)轉換為可列印的字元,使其可在網路傳輸中安全使用。 Uuencode 編碼的資料比原始資料大約 35%。

注意: convert_uuencode() 不會產生 beginend 行,它們是 uuencode 編碼*檔案*的一部分。

參數

string

要編碼的資料。

傳回值

傳回 uuencode 編碼的資料。

更新日誌

版本 說明
8.0.0 在此版本之前,嘗試轉換空字串會無故傳回 false

範例

範例 #1 convert_uuencode() 範例

<?php
$some_string
= "test\ntext text\r\n";

echo
convert_uuencode($some_string);
?>

以上範例會輸出:

0=&5S=`IT97AT('1E>'0-"@``
`

另請參閱

新增註解

使用者貢獻的註解 2 則註解

root at mantoru dot de
17 年前
@Craig 的註解:base64_encode() 更適合用於此目的。事實上,它產生的輸出更小,執行速度也略快。我做了一個小型的基準測試——以下是我的發現

檔案:JPG,631614 位元組

== Base64 ==
執行時間:0.0039639472961426 秒
輸出長度:842152

== UUencode ==
執行時間:0.004105806350708 秒
輸出長度:870226
zash at zash dot se
16 年前
請注意,使用 base64 或 uuencode 將資料儲存在資料庫中相當沒有效率。如果您正確地跳脫資料並使用二進位欄位(BLOB 等),就不會有問題。
To Top