Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                

PHP - convert_uuencode() Function



The PHP convert_uuencode() function is used to encode a given string into uuencoded format. A "uuencoded" string is a representation of binary data encoded in "ASCII" text format using the UUencoding method.

You can use the convert_uudecode() function together to do a reverse operation. It decodes a uuencoded string back into its original binary format.

Syntax

Following is the syntax of the PHP convert_uuencode() function −

convert_uuencode(string $str): string

Parameters

This function accepts a single parameter, which is described below −

  • str − The string (data) to be encoded.

Return Value

This function returns the uuencoded data. (Before the current version 8.0.0, if you try to convert an empty string returns false for no particular reason.)

Example 1

The following is the basic example of the PHP convert_uuencode() function −

<?php
   $str = "I Love PHP!";
   echo "The given uuencoded string: $str";
   echo "\nThe decoded string is: ";
   #using convert_uuencode() function
   echo convert_uuencode($str);
?>

Output

The above program generates the following output −

The given uuencoded string: I Love PHP!
The decoded string is: +22!,;W9E(%!(4"$`
`

Example 2

Using theconvert_uuencode()andconvert_uuencode()functions together to encode and decode data at a time.

Following is another example of the PHP convert_uuencode() function. We use this function to decode a uuencoded string "Hey!, Tutorialspoint" −

<?php
   $str = "Hey!, Tutorialspoint";
   echo "The given uuencoded string: $str";
   echo "\nThe encoded string is: ";
   #using convert_uuencode() function
   echo convert_uuencode($str);
   echo "The decoded string is: ";
   #using convert_uuencode() function
   echo convert_uudecode(convert_uuencode($str));
?>

Output

After executing the above program, the following output will be displayed −

The given uuencoded string: Hey!, Tutorialspoint
The encoded string is: 42&5Y(2P@5'5T;W)I86QS<&]I;G0`
`
The decoded string is: Hey!, Tutorialspoint
php_function_reference.htm
Advertisements