©
Ce document utilise Manuel du site Web PHP chinois Libérer
(PHP 5)
convert_uuencode — 使用 uuencode 编码一个字符串
$data
)convert_uuencode() 使用 uuencode 算法对一个字符串进行编码。
uuencode 算法会将所有(含二进制)字符串转化为可输出的字符, 并且可以被安全的应用于网络传输。使用 uuencode 编码后的数据 将会比源数据大35%左右
data
需要被编码的数据。
返回 uuencode 编码后的数据 或者在失败时返回 FALSE
。
Example #1 convert_uuencode() 例子
<?php
$some_string = "test\ntext text\r\n" ;
echo convert_uuencode ( $some_string );
?>
[#1] abc518 at gmail dot com [2008-09-26 13:06:55]
Using uuencode for passwords isn't any more secure than plain text (maybe slightly: non-developers or too lazy to figure out what you used). mcrypt or even md5 is much more secure.
[#2] zash at zash dot se [2008-05-30 00:30:47]
note that using base64 or uuencode to store data in a database is pretty useless. if you properly escape your data and use a binary field (BLOB etc) there is no problem.
[#3] allali at labri dot fr [2008-04-02 00:06:56]
if you want to use convert_uuencode with command uudecode you must insert a line "begin %s %s\n" at the beginning and "end\n" at the end:
<?php
echo "begin 644 hello.txt\n";
echo convert_uuencode("hello");
echo "end\n";
?>
the first arg. after begin is the mode (destination file rights), the second is the destination file name.
Then you can do a wget followed by a uudecode.
JA.
[#4] root at mantoru dot de [2007-11-10 09:29:20]
@Craig's note: base64_encode() is better suited for that. In fact, it produces smaller output and operates slightly faster. I did a little benchmark -- here are my findings:
File: JPG, 631614 bytes
== Base64 ==
execution time: 0.0039639472961426 secs
output length: 842152
== UUencode ==
execution time: 0.004105806350708 secs
output length: 870226
[#5] tmaschler at NOSPAM dot ditf-denkendorf dot de [2006-09-20 01:46:41]
Note to the tip of Craig at frostycoolslug dot com:
If you are using fulltext functionality on columns with uuencoded texts, collations will not work. You might prefer to pass the text escaped to the database engine.
[#6] nmmm at nmmm dot nu [2006-04-12 08:17:51]
uuencode is recognisable as email attachment in Ms Outlook, but in Outlook Express (at least in older versions) - is not.
This is shell script, but it may give you an idea how you can send attachments using uuencode:
cat file.bin | uuencode file.bin | mail someone@domain.com -s "file.bin"
uuencode mail attachments from other point of wiev are deprecated. However I use such technic for years now and it work well.
[#7] aidan at php dot net [2005-05-29 08:51:43]
This functionality is now implemented in the PEAR package PHP_Compat.
More information about using this function without upgrading your version of PHP can be found on the below link:
http://pear.php.net/package/PHP_Compat