Encode and Decode query string value in php

There are many ways to encode and decode PHP code.From the perspective of site security, there are three PHP functions — str_rot13(), base64_encode(), and gzinflate — that are frequently used to encode and decode strings of PHP code.

Encode and decode with base64_encode() & base64_decode()

In this tutorial I will be explaining how to encode and decode query string value in PHP.


base64_encode — Encodes data with MIME base64.

Encodes the given data with base64.

This encoding is designed to make binary data survive transport through transport layers that are not 8-bit clean, such as mail bodies.

Base64-encoded data takes about 33% more space than the original data.

The encoded data, as a string or FALSE on failure.




base64_decode — Decodes data encoded with MIME base64

Decodes a base64 encoded data.

The encoded data.

If the strict parameter is set to TRUE then the base64_decode() function will return FALSE if the input contains character from outside the base64 alphabet. Otherwise invalid characters will be silently discarded.

Returns the original data or FALSE on failure. The returned data may be binary.



You may also like

Leave a Reply

Your email address will not be published. Required fields are marked *