dongxun2089 2017-03-08 14:19
浏览 28
已采纳

声明变量php [重复]时出错

This question already has an answer here:

I want to Declaring variable

and I get error

Parse error: syntax error, unexpected 'book' (T_STRING)

mycode

$filters = "library&loc=local,scope:("book")&loc=local,scope:("book2")....";
$path = "http://xxxxx/place/search/institution=".$filters."";

in line $filters=..... is error

and I don't want to change "..." to '...' because my result is change

</div>
  • 写回答

5条回答 默认 最新

  • dqoys62082 2017-03-08 14:21
    关注

    You need to escape the double quotes:

    $filters = "library&loc=local,scope:(\"book\")&loc=local,scope:(\"book2\")....";
    

    Alternatively, you can use single quotes for the entire string:

    $filters = 'library&loc=local,scope:("book")&loc=local,scope:("book2")....';
    

    Both of these result in the same string which is library&loc=local,scope:("book")&loc=local,scope:("book2")....

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(4条)

报告相同问题?

悬赏问题

  • ¥500 52810做蓝牙接受端
  • ¥15 基于PLC的三轴机械手程序
  • ¥15 多址通信方式的抗噪声性能和系统容量对比
  • ¥15 winform的chart曲线生成时有凸起
  • ¥15 msix packaging tool打包问题
  • ¥15 finalshell节点的搭建代码和那个端口代码教程
  • ¥15 Centos / PETSc / PETGEM
  • ¥15 centos7.9 IPv6端口telnet和端口监控问题
  • ¥20 完全没有学习过GAN,看了CSDN的一篇文章,里面有代码但是完全不知道如何操作
  • ¥15 使用ue5插件narrative时如何切换关卡也保存叙事任务记录