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条)

报告相同问题?