PHP base64_decode()

📔 : PHP 🔗

base64_decode() function, base64 encoded string को decode करता है।

PHP base64_decode Syntax

base64_decode ( string $string , bool $strict = false );
  1. string $string | required : base64 encoded string, जिसे decode करना है।

  2. bool $strict = false | optional : strict parameter Boolean value true / false accept करता है। true का मतलब अगर input string में base64 alphabet के अलावा दूसरे characters भी हैं तो सिर्फ false return होगा otherwise उन characters को बाहर निकाल दिया जायगा। By Default false ही set होता है।

  3. Return Value : successfully string decode होने पर decoded string return होगी otherwise false.

PHP base64_decode Example

<?php
  $str = "SGVsbG8gd29ybGQgIQ==";
  echo base64_decode($str);
?>

Output
Hello world !

अब अगर इस encoded string में हम अपनी तरफ से कुछ add करें , तो base64_decode() function उसे evaluate नहीं करेगा।

<?php
    $str = "SGVsbG8gd29ybGQgIQ==1";
    var_dump(base64_decode($str));
    echo "<br>";
    var_dump(base64_decode($str, true));
?>

Output
string(14) "Hello world ! " bool(false)

Related Topics :

Rahul Kumar

Rahul Kumar

Hi ! I'm Rahul Kumar Rajput founder of learnhindituts.com. I'm a software developer having more than 4 years of experience. I love to talk about programming as well as writing technical tutorials and blogs that can help to others. I'm here to help you navigate the coding cosmos and turn your ideas into reality, keep coding, keep learning :)

Get connected with me. :) LinkedIn Twitter Instagram Facebook