PHP Base64 encoding decoding a variable


To convert a PHP variable to Base64 String we can make use of base64_encode() function,

Syntax : String base64_encode(String $var);

Code Examples :
<?php

    $data = "This is the text to be converted to Base64 string @ $ % ^ & * #@ %& &* &^( " ;

    $base64EncodedData = base64_encode($data);
  
    echo $base64EncodedData;

?>

Output : VGhpcyBpcyB0aGUgdGV4dCB0byBiZSBjb252ZXJ0ZWQgdG8gQmFzZTY0IHN0cmluZyBAICQgJSBeICYgKiAjQCAlJiAmKiAmXigg



















Copyright © Code2care 2024 | Privacy Policy | About Us | Contact Us | Sitemap