Bug #68116 [Opn->Nab]: The code is same but it display different output
Edit report at https://bugs.php.net/bug.php?id=68116&edit=1
ID: 68116
Updated by: leigh@php.net
Reported by: kabir dot pust at gmail dot com
Summary: The code is same but it display different output
-Status: Open
+Status: Not a bug
Type: Bug
Package: Output Control
Operating System: Ubuntu
PHP Version: 5.4.33
Block user comment: N
Private report: N
New Comment:
Sorry but this is not a bug.
The base64_encoded version of 'masud' will have a single equals sign at the end for
padding.
When you urlencode this it will be converted to '%3D',
bWFzdWQ= -> bWFzdWQ%3D
You have changed the encoding, and have changed the value represented by this encoding.
base64_decode is behaving correctly in this case.
Thank you for your interest in PHP.
Previous Comments:
------------------------------------------------------------------------
[2014-09-29 12:28:26] kabir dot pust at gmail dot com
Description:
------------
<?php
echo $a = urlencode(base64_encode('fazlul')).' ';
echo $str = @iconv('UTF-8', 'UTF-8//IGNORE', $a).' ';
echo $c = urldecode(base64_decode($str));
echo "\r\n\r\n";
echo $a = urlencode(base64_encode('masud')).' ';//same for karim
echo $str = @iconv('UTF-8', 'UTF-8//IGNORE', $a).' ';
echo $c = urldecode(base64_decode($str));
Test script:
---------------
Same process but the output is different.
Expected result:
----------------
input: fazlul
output: fazlul
But,
input: masud
output: masud
Actual result:
--------------
input: fazlul
output: fazlul
But,
input: masud
output: masud7
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=68116&edit=1
Thread (4 messages)