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 ! My name is Rahul Kumar Rajput. I'm a back end web developer and founder of learnhindituts.com. I live in Uttar Pradesh (UP), India and I love to talk about programming as well as writing technical tutorials and tips that can help to others.

Get connected with me. :) LinkedIn Twitter Instagram Facebook