PHP Function Base64_Encode
php function base64_encode is used to encode binary data into a printable ASCII string format. This is done in order to protect the original data from being modified while in transit through transmission media and protocols that may not understand or handle binary data correctly. It is also commonly used to obfuscate auto-increment primary keys in databases when they are displayed to users in URIs or API calls.
There are a number of ways to perform this conversion in PHP, including the built-in function base64_encode and the built-in function base64_decode. Both functions take one string as input and return the resulting decoded string. The base64_decode function will return FALSE on failure, or if the string being decoded contains characters that fall outside of the base64 alphabet. The base64_decode function can be called with a second argument that, when passed TRUE, will force the decoder to perform strict string checking. This will ensure that the decoded string does not contain any invalid characters. It is recommended that this optional argument be passed if you are concerned that your output might include any characters not in the base64 alphabet, or you want to ensure that the decoded string will not produce any invalid output.
Alternatively, you can use the json_encode and json_decode functions to convert between a base64-encoded string and a json object. This is useful if you want to use a json object in an array, or to work with the array elements using a json library.