What is the difference between encoding and encryption in PHP, and how does base64 fit into this distinction?

Encoding is the process of converting data into a format that is suitable for a specific type of transmission or storage, such as converting text into a format that can be safely transmitted over the internet. Encryption, on the other hand, is the process of converting data into a secure format that can only be accessed with a specific key or password. Base64 is a type of encoding that converts binary data into a text format, but it is not a form of encryption as it can be easily decoded.

// Encoding data using base64
$data = 'Hello, world!';
$encoded_data = base64_encode($data);
echo $encoded_data;

// Decoding data using base64
$decoded_data = base64_decode($encoded_data);
echo $decoded_data;