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,
- Upload Pdf file using PHP Script
- 403 forbidden error for Image
- Installing vue.js in Laravel 8
- Copy file from one directory to other in Php
- Remove URL Forward Slash Before Single or Double quotes in php.ini
- PHP Script to Upload Images to Server
- PHP Base64 encoding decoding a variable
- Upload docx file using PHP script
- Delete file using PHP code : unlink()
- PHP 301 Redirect Permanently
- PHP Fatal error : Call to a member function bind_param() on a non-object
- Call PHP function on Button click using jquery ajax
- PHP header location function not called
- Failed to load resource: net::ERR_CACHE_MISS PHP
- PHP Code for sending Emails
- How to destroy PHP session()
- PHP drag and drop file upload tutorial using dropzone.js
- PHP Warning: Cannot modify header information - headers already sent
More Posts:
- Fetch More then 10 Links Per Page in Google Search Result - Google
- Android Studio: Cannot perform refactoring operation - Android-Studio
- eclipse maven m2e : Cannot complete the install - Eclipse
- Top 3 Awesome Text Editors developers prefer at workplace - Sublime
- Calculate Area of a Rectangle - C-Program
- What is Bootstrap Jumbotron and how to use it - Bootstrap
- Background task activation is spurious error - Windows 10, Office 2016, Office 365 - HowTos
- How to remove old 404 pages ulrs from Google crawler - Html
- Exception in thread main java.lang.NoClassDefFoundError: package javaClass - Java
- SharePoint Server 2016 error Microsoft Office Online Server 2016 cant be installed on the same machine as a Microsoft SharePoint Server product - SharePoint
- 7 deadly java.lang.OutOfMemoryError in Java Programming - Java
- How to Print from JavaScript HTML using window.print - JavaScript
- Unable to establish connection to adb : Android Studio Error - Android
- How to send WhatsApp message from your Android App using Intent - WhatsApp
- Portable Notepad++ for windows - NotepadPlusPlus