-1

I am trying to use this code:

 <?php  echo json_decode('"\uD83D\uDE00"'); ?>

When I am using this code I am getting this value :

 

But when I am trying to use this code using some variable like this:

 <?php
 $var = "\uD83D\uDE00";
 echo json_decode('"{$var}"');
 echo "{$var}";
 ?>

I am getting this as output:

 {$var}\uD83D\uDE00

I have tried many things but nothing is working what can be the best way to do this.

3 Answers3

1

It is strange as demand but funny, try this :)

<?php
    $var = "\uD83D\uDE00"; 
    echo json_decode('"'.$var.'"');
?>
1

Try this:

 <?php
    $var  ='"\uD83D\uDE00"';
      echo json_decode($var); 
?>
B. Desai
  • 16,414
  • 5
  • 26
  • 47
0

Please try this

  <?php 
     $var = "\uD83D\uDE00";
     echo json_decode($var);
     echo $var;
    ?>