[英]Encoding JSON with spaces in string in PHP from a PHP Session before passing it to Vue.js
I am encoding JSON with spaces in the string in PHP before passing it to Vue.js, however the process is failing. 在将字符串传递给Vue.js之前,我在PHP中使用字符串在空格中编码JSON,但是该过程失败了。 If I test without the spaces everything is fine.
如果我没有空格测试,一切都很好。
I am sure there is a basic bit of theory than I am just not aware of but if someone could explain that would great. 我敢肯定,有一些理论基础比我不了解的要多,但是如果有人可以解释的话,那会很棒。
The encoding code is below: 编码代码如下:
<?php $f = Session::get('foods');?>
<?php $a = json_encode($f); ?>
Passing to Vue 传递给Vue
<credits f = {{$a}} a = {{$b}} c={{$cr}}></credits>
如果属性可以有空格,则需要在属性两边加上引号。
<credits f='{{$a}}' a='{{$b}}' c='{{$cr}}'></credits>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.