{"id":15014,"date":"2016-10-27T16:15:06","date_gmt":"2016-10-27T13:15:06","guid":{"rendered":"http:\/\/www.webcodegeeks.com\/?p=15014"},"modified":"2018-01-09T10:14:34","modified_gmt":"2018-01-09T08:14:34","slug":"php-base64-encodedecode-example","status":"publish","type":"post","link":"https:\/\/www.webcodegeeks.com\/php\/php-base64-encodedecode-example\/","title":{"rendered":"PHP Base64 Encode\/Decode Example"},"content":{"rendered":"<p>Encoding in base64 simply involves converting binary data to ASCII text. Encoding in base64 is done so as to easily and effectively transfer binary data over a network. One of its use case is transferring data in emails.<br \/>\n&nbsp;<br \/>\n&nbsp;<br \/>\n&nbsp;<br \/>\n&nbsp;<br \/>\n&nbsp;<br \/>\n&nbsp;<br \/>\n&nbsp;<br \/>\n&nbsp;<br \/>\n&nbsp;<br \/>\n[ulp id=&#8217;8njY7i2QRy6sg8pg&#8217;]<br \/>\n&nbsp;<br \/>\nIn this example we are going to learn how to encode and decode data in base64 using PHP.<br \/>\nFor this example we will use:<\/p>\n<ul>\n<li>A computer with PHP&gt;= 5.5 installed<\/li>\n<li>notepad++<\/li>\n<\/ul>\n<h2>1. Getting Started<\/h2>\n<p>It is not safe to transfer raw binary data over a network simply because the data can get corrupted before it gets to the desired destination. Binary data can be corrupted because the underlying protocol might think that you&#8217;ve entered a special character combination ( the underlying protocol can miss interpret the contents in the data being transffered through it) or some other reasons.<\/p>\n<p>To avoid the corruption of data and unnneccessary headaches that accompanies it, encoding is required. If data is encoded then definitly it has to be decoded, so the receiving end can correctly manipulate it.<br \/>\nBase64 is one way of encoding and decoding raw binary data into ASCII text. Though base64 tends to increase the total size of the data ( by 30 percent) it is still widely used.<\/p>\n<h3>1.1 base64 data<\/h3>\n<p>Below is an example a string encoded in base64.<\/p>\n<p><span style=\"text-decoration: underline;\"><em>index2.html<\/em><\/span><\/p>\n<pre class=\"brush:html; hightlight 24; wrap-lines:false\">&lt;!DOCTYPE html&gt; \r\n&lt;html lang=en&gt;\r\n\t&lt;head&gt;\r\n\t&lt;style&gt;\r\n\thtml, body{\r\n\twidth:100%;\r\n\theight:100%;\r\n\tmargin:0%;\r\n\tfont-family:\"helvetica\",\"verdana\",\"calibri\", \"san serif\";\r\n\toverflow:hidden;\r\n\tpadding:0%;\r\n\tborder:0%;\r\n\t}\r\n\t \r\n\t&lt;\/style&gt;\r\n\t \t\t&lt;meta charset=\"utf-8\" \/&gt;\r\n\t\t&lt;meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no, target-densitydpi=device-dpi\"\/&gt;\r\n\t\r\n\t&lt;title&gt;base64 encode and decode &lt;\/title&gt;\r\n\t\r\n\t&lt;\/head&gt;\r\n\t&lt;body&gt;\r\n\r\nUGFsYXBhIHdlYiBzZXJ2ZXIgaXMgYSBtb2JpbGUgc2VydmVyIGZvciBhbmRyb2lkIG9wZXJhdGluZyBzeXN0ZW0uIFRoZSBwYWNrYWdlIGluY2x1ZGVzIHRoZSBMaWdodHRwZCB3ZWIgc2VydmVyLCBQSFAsIE15U1FMLCBhbmQgTVNNVFAuIEl0IHR1cm5zIHlvdXIgZGV2aWNlcyBiYXNlZCBvbiBhbmRyb2lkIG9wZXJhdGluZyBzeXN0ZW0gaW50byBhIHdlYiBzZXJ2ZXIgYW5kIGRhdGFiYXNlIHNlcnZlciwgc3VpdGFibGUgZm9yIGJ1aWxkaW5nIGR5bmFtaWMgd2ViIHNpdGVzLiBQV1MgdmVyc2lvbiAyLjAuMCBvciBsYXRlciBpbmNsdWRlcyBzdXBwb3J0IGZvciBkZXZpY2VzIHRoYXQgdXNlIEFSTSAmIEludGVsICh4ODYpIHByb2Nlc3Nvci4KClBhbGFwYSB3ZWIgc2VydmVyIGlzIGEgZ3JlYXQgc2VydmVyIGZvciBhbmRyb2lkIG9wZXJhdGluZyBzeXN0ZW0gYW5kIGEgZ3JlYXQgdG9vbCBmb3IgcGVvcGxlIHdobyBqdXN0IHN0YXJ0ZWQgbGVhcm5pbmcgcHJvZ3JhbW1pbmcgd2l0aCBQSFAgKG9yIGV2ZW4gUEhQIGd1cnVzKS4KCkl0IGlzIHZlcnkgZWFzeSB0byB1c2UsIHdpdGggb25lIHRvdWNoIHlvdSBjYW4gZ2V0IHRoZSB3ZWIgc2VydmVyIHVwIGFuZCBydW5uaW5nLiBXaXRoIGFub3RoZXIgdG91Y2ggeW91IGNhbiBnZXQgdGhlIGRhdGFiYXNlIHNlcnZlciB3b3JraW5nLg==\r\n\r\n\t&lt;\/body&gt;\r\n\t&lt;\/html&gt;\r\n\r\n<\/pre>\n<p>See line 24 for data encoded in base64.<\/p>\n<p><span style=\"text-decoration: underline;\"><em>index.html<\/em><\/span><\/p>\n<pre class=\"brush:html; highlight[24,25,26,27,28,29]\">&lt;!DOCTYPE html&gt; \r\n&lt;html lang=en&gt;\r\n\t&lt;head&gt;\r\n\t&lt;style&gt;\r\n\thtml, body{\r\n\twidth:100%;\r\n\theight:100%;\r\n\tmargin:0%;\r\n\tfont-family:\"helvetica\",\"verdana\",\"calibri\", \"san serif\";\r\n\toverflow:hidden;\r\n\tpadding:0%;\r\n\tborder:0%;\r\n\t}\r\n\t \r\n\t&lt;\/style&gt;\r\n\t \t\t&lt;meta charset=\"utf-8\" \/&gt;\r\n\t\t&lt;meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no, target-densitydpi=device-dpi\"\/&gt;\r\n\t\r\n\t&lt;title&gt;base64 encode and decode &lt;\/title&gt;\r\n\t\r\n\t&lt;\/head&gt;\r\n\t&lt;body&gt;\r\n\r\nPalapa web server is a mobile server for android operating system. The package includes the Lighttpd web server, PHP, MySQL, and MSMTP. It turns your devices based on android operating system into a web server and database server, suitable for building dynamic web sites. PWS version 2.0.0 or later includes support for devices that use ARM &amp; Intel (x86) processor.\r\n\r\nPalapa web server is a great server for android operating system and a great tool for people who just started learning programming with PHP (or even PHP gurus).\r\n\r\nIt is very easy to use, with one touch you can get the web server up and running. With another touch you can get the database server working.\r\n\t\r\n\r\n\t&lt;\/body&gt;\r\n\t&lt;\/html&gt;\r\n\r\n<\/pre>\n<p>In between the body tags is the string that was encoded to base64.<\/p>\n<h3>1.2 Encoding to base64<\/h3>\n<p>Encoding data to base64 in PHP is quite easy, all we need to do is call the method <code> base64_encode ( string $data ) <\/code>. <code>$data <\/code>is the string we want to encode to base64.<\/p>\n<p><span style=\"text-decoration: underline;\"><em>index.php<\/em><\/span><\/p>\n<pre class=\"brush:php\">&lt;!DOCTYPE html&gt; \r\n&lt;html lang=en&gt;\r\n\t&lt;head&gt;\r\n\t&lt;style&gt;\r\n\thtml, body{\r\n\twidth:100%;\r\n\theight:100%;\r\n\tmargin:0%;\r\n\tfont-family:\"helvetica\",\"verdana\",\"calibri\", \"san serif\";\r\n\tpadding:0%;\r\n\tborder:0%;\r\n\t}\r\n\t \r\n\t&lt;\/style&gt;\r\n\t \t\t&lt;meta charset=\"utf-8\" \/&gt;\r\n\t\t&lt;meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no, target-densitydpi=device-dpi\"\/&gt;\r\n\t\r\n\t&lt;title&gt;FootBall Manager&lt;\/title&gt;\r\n\t\r\n\t&lt;\/head&gt;\r\n\t&lt;body&gt;\r\n\r\n\t&lt;?php\r\n$e=\"Palapa web server is a mobile server for android operating system. The package includes the Lighttpd web server, PHP, MySQL, and MSMTP. It turns your devices based on android operating system into a web server and database server, suitable for building dynamic web sites. PWS version 2.0.0 or later includes support for devices that use ARM &amp; Intel (x86) processor.\r\n\r\nPalapa web server is a great server for android operating system and a great tool for people who just started learning programming with PHP (or even PHP gurus).\r\n\r\nIt is very easy to use, with one touch you can get the web server up and running. With another touch you can get the database server working.\";\r\n\r\necho base64_encode ($e);\/\/ encodes the string in variable  $e into base64 and print the returned value\r\n\r\n?&gt;\r\n\r\n\t&lt;\/body&gt;\r\n\t&lt;\/html&gt;\r\n<\/pre>\n<h3>1.3 decoding base64<\/h3>\n<p>To decode data encoded with base64 we use the function <code>base64_decode($str)<\/code>. <code>$str<\/code> represents the encoded data.<\/p>\n<p><span style=\"text-decoration: underline;\"><em>index2.php<\/em><\/span><\/p>\n<pre class=\"brush:php; wrap-lines:false\">&lt;!DOCTYPE html&gt; \r\n&lt;html lang=en&gt;\r\n\t&lt;head&gt;\r\n\t&lt;style&gt;\r\n\thtml, body{\r\n\twidth:100%;\r\n\theight:100%;\r\n\tmargin:0%;\r\n\tfont-family:\"helvetica\",\"verdana\",\"calibri\", \"san serif\";\r\n\tpadding:0%;\r\n\tborder:0%;\r\n\t}\r\n\t \r\n\t&lt;\/style&gt;\r\n\t \t\t&lt;meta charset=\"utf-8\" \/&gt;\r\n\t\t&lt;meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no, target-densitydpi=device-dpi\"\/&gt;\r\n\t\r\n\t&lt;title&gt;FootBall Manager&lt;\/title&gt;\r\n\t\r\n\t&lt;\/head&gt;\r\n\t&lt;body&gt;\r\n\r\n\t&lt;?php\r\n$e=\"UGFsYXBhIHdlYiBzZXJ2ZXIgaXMgYSBtb2JpbGUgc2VydmVyIGZvciBhbmRyb2lkIG9wZXJhdGluZyBzeXN0ZW0uIFRoZSBwYWNrYWdlIGluY2x1ZGVzIHRoZSBMaWdodHRwZCB3ZWIgc2VydmVyLCBQSFAsIE15U1FMLCBhbmQgTVNNVFAuIEl0IHR1cm5zIHlvdXIgZGV2aWNlcyBiYXNlZCBvbiBhbmRyb2lkIG9wZXJhdGluZyBzeXN0ZW0gaW50byBhIHdlYiBzZXJ2ZXIgYW5kIGRhdGFiYXNlIHNlcnZlciwgc3VpdGFibGUgZm9yIGJ1aWxkaW5nIGR5bmFtaWMgd2ViIHNpdGVzLiBQV1MgdmVyc2lvbiAyLjAuMCBvciBsYXRlciBpbmNsdWRlcyBzdXBwb3J0IGZvciBkZXZpY2VzIHRoYXQgdXNlIEFSTSAmIEludGVsICh4ODYpIHByb2Nlc3Nvci4KClBhbGFwYSB3ZWIgc2VydmVyIGlzIGEgZ3JlYXQgc2VydmVyIGZvciBhbmRyb2lkIG9wZXJhdGluZyBzeXN0ZW0gYW5kIGEgZ3JlYXQgdG9vbCBmb3IgcGVvcGxlIHdobyBqdXN0IHN0YXJ0ZWQgbGVhcm5pbmcgcHJvZ3JhbW1pbmcgd2l0aCBQSFAgKG9yIGV2ZW4gUEhQIGd1cnVzKS4KCkl0IGlzIHZlcnkgZWFzeSB0byB1c2UsIHdpdGggb25lIHRvdWNoIHlvdSBjYW4gZ2V0IHRoZSB3ZWIgc2VydmVyIHVwIGFuZCBydW5uaW5nLiBXaXRoIGFub3RoZXIgdG91Y2ggeW91IGNhbiBnZXQgdGhlIGRhdGFiYXNlIHNlcnZlciB3b3JraW5nLg\";\r\n\r\necho base64_decode ($e);\/\/ decode data encoded with base64 and print out the string returned\r\n\r\n\r\n\r\n\r\n?&gt;\r\n\r\n\t&lt;\/body&gt;\r\n\t&lt;\/html&gt;\r\n\r\n\r\n\r\n<\/pre>\n<h2>2. Summary<\/h2>\n<p>We learnt about encoding and decoding data in base64. We learnt why it is neccessary or even compulsory to do it. We also carried out some practical examples using PHP functions to encode and decode with base64.<\/p>\n<h2>3. Download the source code<\/h2>\n<p>Download the source code for this tutorial:<\/p>\n<div class=\"download\">\n<p><strong>Download<\/strong><br \/>\nYou can download the full source code of this example here:\u00a0<strong><a href=\"http:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2016\/10\/base64encodedecodeexample.zip\">base64encodedecodeexample<\/a><\/strong><\/p>\n<p>&nbsp;<\/p>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>Encoding in base64 simply involves converting binary data to ASCII text. Encoding in base64 is done so as to easily and effectively transfer binary data over a network. One of its use case is transferring data in emails. &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; [ulp id=&#8217;8njY7i2QRy6sg8pg&#8217;] &nbsp; In this example we are &hellip;<\/p>\n","protected":false},"author":164,"featured_media":930,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[10],"tags":[400,122,399],"class_list":["post-15014","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-php","tag-base-64-decode","tag-php","tag-php-base-64-encode"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v26.5 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>PHP Base64 Encode\/Decode Example - Web Code Geeks - 2026<\/title>\n<meta name=\"description\" content=\"Encoding in base64 simply involves converting binary data to ASCII text. Encoding in base64 is done so as to easily and effectively transfer binary data\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.webcodegeeks.com\/php\/php-base64-encodedecode-example\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"PHP Base64 Encode\/Decode Example - Web Code Geeks - 2026\" \/>\n<meta property=\"og:description\" content=\"Encoding in base64 simply involves converting binary data to ASCII text. Encoding in base64 is done so as to easily and effectively transfer binary data\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.webcodegeeks.com\/php\/php-base64-encodedecode-example\/\" \/>\n<meta property=\"og:site_name\" content=\"Web Code Geeks\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/webcodegeeks\" \/>\n<meta property=\"article:published_time\" content=\"2016-10-27T13:15:06+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2018-01-09T08:14:34+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/10\/php-logo.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"150\" \/>\n\t<meta property=\"og:image:height\" content=\"150\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"Olayemi Odunayo\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@webcodegeeks\" \/>\n<meta name=\"twitter:site\" content=\"@webcodegeeks\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Olayemi Odunayo\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"6 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/www.webcodegeeks.com\/php\/php-base64-encodedecode-example\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/php\/php-base64-encodedecode-example\/\"},\"author\":{\"name\":\"Olayemi Odunayo\",\"@id\":\"https:\/\/www.webcodegeeks.com\/#\/schema\/person\/417918d9b5811210265e8590509718b8\"},\"headline\":\"PHP Base64 Encode\/Decode Example\",\"datePublished\":\"2016-10-27T13:15:06+00:00\",\"dateModified\":\"2018-01-09T08:14:34+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/php\/php-base64-encodedecode-example\/\"},\"wordCount\":372,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/#organization\"},\"image\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/php\/php-base64-encodedecode-example\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/10\/php-logo.jpg\",\"keywords\":[\"base 64 decode\",\"php\",\"PHP base 64 encode\"],\"articleSection\":[\"PHP\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/www.webcodegeeks.com\/php\/php-base64-encodedecode-example\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.webcodegeeks.com\/php\/php-base64-encodedecode-example\/\",\"url\":\"https:\/\/www.webcodegeeks.com\/php\/php-base64-encodedecode-example\/\",\"name\":\"PHP Base64 Encode\/Decode Example - Web Code Geeks - 2026\",\"isPartOf\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/php\/php-base64-encodedecode-example\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/php\/php-base64-encodedecode-example\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/10\/php-logo.jpg\",\"datePublished\":\"2016-10-27T13:15:06+00:00\",\"dateModified\":\"2018-01-09T08:14:34+00:00\",\"description\":\"Encoding in base64 simply involves converting binary data to ASCII text. Encoding in base64 is done so as to easily and effectively transfer binary data\",\"breadcrumb\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/php\/php-base64-encodedecode-example\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.webcodegeeks.com\/php\/php-base64-encodedecode-example\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.webcodegeeks.com\/php\/php-base64-encodedecode-example\/#primaryimage\",\"url\":\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/10\/php-logo.jpg\",\"contentUrl\":\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/10\/php-logo.jpg\",\"width\":150,\"height\":150},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.webcodegeeks.com\/php\/php-base64-encodedecode-example\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.webcodegeeks.com\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"PHP\",\"item\":\"https:\/\/www.webcodegeeks.com\/category\/php\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"PHP Base64 Encode\/Decode Example\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.webcodegeeks.com\/#website\",\"url\":\"https:\/\/www.webcodegeeks.com\/\",\"name\":\"Web Code Geeks\",\"description\":\"Web Developers Resource Center\",\"publisher\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.webcodegeeks.com\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/www.webcodegeeks.com\/#organization\",\"name\":\"Exelixis Media P.C.\",\"url\":\"https:\/\/www.webcodegeeks.com\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.webcodegeeks.com\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png\",\"contentUrl\":\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png\",\"width\":864,\"height\":246,\"caption\":\"Exelixis Media P.C.\"},\"image\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/www.facebook.com\/webcodegeeks\",\"https:\/\/x.com\/webcodegeeks\"]},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.webcodegeeks.com\/#\/schema\/person\/417918d9b5811210265e8590509718b8\",\"name\":\"Olayemi Odunayo\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.webcodegeeks.com\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/016b2a353262962fceecf5c274161cd9ef60fdf1593ec95e71d37f5fd9b444f6?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/016b2a353262962fceecf5c274161cd9ef60fdf1593ec95e71d37f5fd9b444f6?s=96&d=mm&r=g\",\"caption\":\"Olayemi Odunayo\"},\"description\":\"I am a programmer and web developer, who has experience in developing websites and writing desktop and mobile applications. I have worked with both schematic and schemaless databases. I am also familiar with third party API and working with cloud servers. I do programming on the client side with Java, JavaScript, html, Ajax and CSS while I use PHP for server side programming.\",\"sameAs\":[\"https:\/\/www.webcodegeeks.com\/\"],\"url\":\"https:\/\/www.webcodegeeks.com\/author\/olayemi-odunayo\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"PHP Base64 Encode\/Decode Example - Web Code Geeks - 2026","description":"Encoding in base64 simply involves converting binary data to ASCII text. Encoding in base64 is done so as to easily and effectively transfer binary data","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.webcodegeeks.com\/php\/php-base64-encodedecode-example\/","og_locale":"en_US","og_type":"article","og_title":"PHP Base64 Encode\/Decode Example - Web Code Geeks - 2026","og_description":"Encoding in base64 simply involves converting binary data to ASCII text. Encoding in base64 is done so as to easily and effectively transfer binary data","og_url":"https:\/\/www.webcodegeeks.com\/php\/php-base64-encodedecode-example\/","og_site_name":"Web Code Geeks","article_publisher":"https:\/\/www.facebook.com\/webcodegeeks","article_published_time":"2016-10-27T13:15:06+00:00","article_modified_time":"2018-01-09T08:14:34+00:00","og_image":[{"width":150,"height":150,"url":"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/10\/php-logo.jpg","type":"image\/jpeg"}],"author":"Olayemi Odunayo","twitter_card":"summary_large_image","twitter_creator":"@webcodegeeks","twitter_site":"@webcodegeeks","twitter_misc":{"Written by":"Olayemi Odunayo","Est. reading time":"6 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.webcodegeeks.com\/php\/php-base64-encodedecode-example\/#article","isPartOf":{"@id":"https:\/\/www.webcodegeeks.com\/php\/php-base64-encodedecode-example\/"},"author":{"name":"Olayemi Odunayo","@id":"https:\/\/www.webcodegeeks.com\/#\/schema\/person\/417918d9b5811210265e8590509718b8"},"headline":"PHP Base64 Encode\/Decode Example","datePublished":"2016-10-27T13:15:06+00:00","dateModified":"2018-01-09T08:14:34+00:00","mainEntityOfPage":{"@id":"https:\/\/www.webcodegeeks.com\/php\/php-base64-encodedecode-example\/"},"wordCount":372,"commentCount":0,"publisher":{"@id":"https:\/\/www.webcodegeeks.com\/#organization"},"image":{"@id":"https:\/\/www.webcodegeeks.com\/php\/php-base64-encodedecode-example\/#primaryimage"},"thumbnailUrl":"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/10\/php-logo.jpg","keywords":["base 64 decode","php","PHP base 64 encode"],"articleSection":["PHP"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.webcodegeeks.com\/php\/php-base64-encodedecode-example\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.webcodegeeks.com\/php\/php-base64-encodedecode-example\/","url":"https:\/\/www.webcodegeeks.com\/php\/php-base64-encodedecode-example\/","name":"PHP Base64 Encode\/Decode Example - Web Code Geeks - 2026","isPartOf":{"@id":"https:\/\/www.webcodegeeks.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.webcodegeeks.com\/php\/php-base64-encodedecode-example\/#primaryimage"},"image":{"@id":"https:\/\/www.webcodegeeks.com\/php\/php-base64-encodedecode-example\/#primaryimage"},"thumbnailUrl":"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/10\/php-logo.jpg","datePublished":"2016-10-27T13:15:06+00:00","dateModified":"2018-01-09T08:14:34+00:00","description":"Encoding in base64 simply involves converting binary data to ASCII text. Encoding in base64 is done so as to easily and effectively transfer binary data","breadcrumb":{"@id":"https:\/\/www.webcodegeeks.com\/php\/php-base64-encodedecode-example\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.webcodegeeks.com\/php\/php-base64-encodedecode-example\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.webcodegeeks.com\/php\/php-base64-encodedecode-example\/#primaryimage","url":"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/10\/php-logo.jpg","contentUrl":"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/10\/php-logo.jpg","width":150,"height":150},{"@type":"BreadcrumbList","@id":"https:\/\/www.webcodegeeks.com\/php\/php-base64-encodedecode-example\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.webcodegeeks.com\/"},{"@type":"ListItem","position":2,"name":"PHP","item":"https:\/\/www.webcodegeeks.com\/category\/php\/"},{"@type":"ListItem","position":3,"name":"PHP Base64 Encode\/Decode Example"}]},{"@type":"WebSite","@id":"https:\/\/www.webcodegeeks.com\/#website","url":"https:\/\/www.webcodegeeks.com\/","name":"Web Code Geeks","description":"Web Developers Resource Center","publisher":{"@id":"https:\/\/www.webcodegeeks.com\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.webcodegeeks.com\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.webcodegeeks.com\/#organization","name":"Exelixis Media P.C.","url":"https:\/\/www.webcodegeeks.com\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.webcodegeeks.com\/#\/schema\/logo\/image\/","url":"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png","contentUrl":"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png","width":864,"height":246,"caption":"Exelixis Media P.C."},"image":{"@id":"https:\/\/www.webcodegeeks.com\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/webcodegeeks","https:\/\/x.com\/webcodegeeks"]},{"@type":"Person","@id":"https:\/\/www.webcodegeeks.com\/#\/schema\/person\/417918d9b5811210265e8590509718b8","name":"Olayemi Odunayo","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.webcodegeeks.com\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/016b2a353262962fceecf5c274161cd9ef60fdf1593ec95e71d37f5fd9b444f6?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/016b2a353262962fceecf5c274161cd9ef60fdf1593ec95e71d37f5fd9b444f6?s=96&d=mm&r=g","caption":"Olayemi Odunayo"},"description":"I am a programmer and web developer, who has experience in developing websites and writing desktop and mobile applications. I have worked with both schematic and schemaless databases. I am also familiar with third party API and working with cloud servers. I do programming on the client side with Java, JavaScript, html, Ajax and CSS while I use PHP for server side programming.","sameAs":["https:\/\/www.webcodegeeks.com\/"],"url":"https:\/\/www.webcodegeeks.com\/author\/olayemi-odunayo\/"}]}},"_links":{"self":[{"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/posts\/15014","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/users\/164"}],"replies":[{"embeddable":true,"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/comments?post=15014"}],"version-history":[{"count":0,"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/posts\/15014\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/media\/930"}],"wp:attachment":[{"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/media?parent=15014"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/categories?post=15014"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/tags?post=15014"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}