Quantcast
Channel: Active questions tagged html - Stack Overflow
Viewing all articles
Browse latest Browse all 74020

How to escape json properly? [duplicate]

$
0
0

I am trying to put a json on an html input. Here is my code:

$data = [
    'name' => addslashes("Maria"),
    'message' => addslashes("It's fun in here."),
];

And on HTML

<input type="text" name="data" value='<?php echo ( json_encode( $data ) ); ?>'>

I added addslashes to the values but I'm still getting this:

enter image description here

Any help would be appreciated.


Viewing all articles
Browse latest Browse all 74020

Trending Articles