imap_binary_basic.phpt 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. --TEST--
  2. Test imap_binary() function : basic functionality
  3. --EXTENSIONS--
  4. imap
  5. --FILE--
  6. <?php
  7. echo "*** Testing imap_binary() : basic functionality ***\n";
  8. echo "Encode as short string\n";
  9. $str = 'This is an example string to be base 64 encoded';
  10. $base64 = imap_binary($str);
  11. var_dump(bin2hex($base64));
  12. echo "Encode a string which results in more than 60 charters of output\n";
  13. $str = 'This is a long string with results in more than 60 characters of output';
  14. $base64 = imap_binary($str);
  15. var_dump(bin2hex($base64));
  16. echo "Encode a string with special characters\n";
  17. $str = '_+-={][];;@~#?/>.<,';
  18. $base64 = imap_binary($str);
  19. var_dump(bin2hex($base64));
  20. echo "Encode some hexadecimal data\n";
  21. $hex = 'x00\x01\x02\x03\x04\x05\x06\xFA\xFB\xFC\xFD\xFE\xFF';
  22. $base64 = imap_binary($hex);
  23. var_dump(bin2hex($base64));
  24. ?>
  25. --EXPECT--
  26. *** Testing imap_binary() : basic functionality ***
  27. Encode as short string
  28. string(136) "5647687063794270637942686269426c654746746347786c49484e30636d6c755a794230627942695a53426959584e6c49445930494756755932396b0d0a5a57513d0d0a"
  29. Encode a string which results in more than 60 charters of output
  30. string(200) "56476870637942706379426849477876626d6367633352796157356e4948647064476767636d567a64577830637942706269427462334a6c4948526f0d0a595734674e6a416759326868636d466a64475679637942765a694276645852776458513d0d0a"
  31. Encode a string with special characters
  32. string(60) "5879737450587464573130374f30422b497a3876506934384c413d3d0d0a"
  33. Encode some hexadecimal data
  34. string(144) "65444177584867774d5678344d444a636544417a584867774e4678344d445663654441325848684751567834526b4a6365455a4458486847524678340d0a526b566365455a470d0a"