laravel - json_encodeing the returned value of trans function sent error when using single quote

136 views Asked by At

I have used this code inside lang folder inside the some_file.php

return [
    'some-text' => 'i\'d like to fix it! it doesn\'t work even if I change the single quotes to double one.',
];

Note that the returned value is correct but when I json_encode the value and print it inside an input hidden tag with {!! json_encode('some_file.some_text') !!} it sends me an error in firebug (I don't remember the code exactly and I have no access the code right now) but it had intermittent json in its error.

1

There are 1 answers

1
Shibon On

Try inside double quotes

return [
'some-text' => "i\'d like to fix it! it doesn\'t work even if I change 
 the single quotes to double one.",
  ];