PHP | base64_encode() Function
The base64_encode() function is an inbuilt function in PHP which is used to Encodes data with MIME base64. MIME (Multipurpose Internet Mail Extensions) base64 is used to encode the string in base64. The base64_encoded data takes 33% more space then original data.
Syntax:
string base64_encode( $data )
Parameters: This function accepts single parameter $data which is mandatory. It is used to specify the string encoding.
Return value: This function returns the encoded string in base64 on success or returns False in case of failure.
Below programs illustrate the base64_encode() function in PHP:
Program 1:
<?php // Program to illustrate base64_encode() // function $str = 'GeeksforGeeks'; echo base64_encode($str); ?> |
R2Vla3Nmb3JHZWVrcw==
Program 2:
<?php // Program to illustrate base64_encode() // function $str = 'GFG, A computer Science Portal For Geeks'; echo base64_encode($str). "\n"; $str = ''; echo base64_encode($str). "\n"; $str = 1; echo base64_encode($str). "\n"; $str = '@#$'; echo base64_encode($str). "\n"; ?> |
R0ZHLCBBIGNvbXB1dGVyIFNjaWVuY2UgUG9ydGFsIEZvciBHZWVrcw== MQ== QCMk
Reference: http://php.net/manual/en/function.base64-encode.php
Recommended Posts:
- How to call a function that return another function in JavaScript ?
- How to get the function name from within that function using JavaScript ?
- PHP | min( ) Function
- PHP Ds\Map sum() Function
- p5.js | sin() function
- p5.js | tan() function
- D3.js | d3.map.set() Function
- D3.js | d3.hcl() Function
- p5.js | log() function
- p5.js | red() function
- PHP | max( ) Function
- p5.js | cos() function
- PHP | pos() Function
- p5.js | max() function
- PHP | key() Function
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.



