PHP 8.5.0 Beta 3 available for testing

Voting

: three minus one?
(Example: nine)

The Note You're Voting On

Rasmus Schultz
7 years ago
In PHP 7, the padding issue with base64_decode() is no more - the following is totally fine:

function base64_encode_url($string) {
return str_replace(['+','/','='], ['-','_',''], base64_encode($string));
}

function base64_decode_url($string) {
return base64_decode(str_replace(['-','_'], ['+','/'], $string));
}

Checked here with random_bytes() and random lengths:

https://3v4l.org/aEs4o

<< Back to user notes page

To Top