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
More Posts related to PHP,
- Delete file using PHP code : unlink()
- PHP header location function not called
- 403 forbidden error for Image
- Call PHP function on Button click using jquery ajax
- How to Pretty Print JSON in PHP
- Step-by-Step Guide: How to Fix - Error Establishing a Database Connection in WordPress
- PHP Base64 encoding decoding a variable
- PHP Fatal error : Call to a member function bind_param() on a non-object
- PHP.ini: How to Remove URL Forward Slash Before Single or Double Quotes
- PHP drag and drop file upload tutorial using dropzone.js
- Upload Pdf file using PHP Script
- PHP Warning: Cannot modify header information - headers already sent
- macOS - cannot calculate MAC address: Using fd 9 hv_vm_create HV_ERROR [PHP XAMPP]
- PHP Code for sending Emails
- How to destroy PHP session()
- Installing vue.js in Laravel 8
- PHP 301 Redirect Permanently
- Upload docx file using PHP script
- Save current timestamp in MySQL using PHP mysqi binding
- Copy file from one directory to other in Php
- Failed to load resource: net::ERR_CACHE_MISS PHP
- PHP Script to Upload Images to Server
More Posts:
- Fix: java: void cannot be dereferenced - Java
- Get Current Local Date and Time using Java 8 DateTime API - Java
- Bootstrap Nav Menu Dropdown on hover - Bootstrap
- Obsolete marquee element alternatives html5 - Html
- Docker Commit Command with Examples - Docker
- How to Check AWS SNS Permissions using CLI - AWS
- Android Studio : Change FAB icon color : FloatingActionButton - Android-Studio
- Capitalize the first letter of each word using Notepad++ - NotepadPlusPlus