How to encode a string with the uuencode algorithm in PHP

In PHP, you can use the convert_uuencode function to encode a string with the uuencode algorithmAn encoding from binary data to text data that originated in Unix programs.

The uuencode algorithm converts all characters into printable ones, which is useful when you need to serialize them.

Note: This function increases the size of the string by about 35%.

Example of what convert_uuencode does

Syntax

convert_uuencode(string $str): string

Parameters

convert_uuencode needs a string $str as the parameter that will be encoded.

Return value

The convert_uuencode function returns a uuencode-encoded string.

Code

The code below shows how the function works.

<?php
$str = "Hello Educative";
$ret_val = convert_uuencode($str);
print($ret_val);

Free Resources