简体   繁体   中英

How to use json_decode in php

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.

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

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

Try this:

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

Please try this

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM