PHP 8.5.0 Alpha 2 available for testing

Voting

: one minus zero?
(Example: nine)

The Note You're Voting On

theking2 at king dot ma
6 months ago
In lieu with biziclop answer here a small upgrade.

<?php
/**
* convert bin to url friendly base64
*/
function base64url_encode( string $data ): string
{
return
rtrim( strtr( base64_encode( $data ), '+/', '-_' ), '=' );
}
/**
* convert url friendly base64 to bin
*/
function base64url_decode( string $data ): string
{
return
base64_decode( strtr( $data, '-_', '+/' ) . str_repeat( '=', 3 - ( 3 + strlen( $data ) ) % 4 ) );
}
?>

This should symmetrically convert one string and back in a url save manner.

<< Back to user notes page

To Top