开发者

php quotes sent along with variable help

开发者 https://www.devze.com 2022-12-18 13:07 出处:网络
I am sending this to a function, and I want double-quotes around the value of the variable below, example $var = \"New York\" (note the quotes)

I am sending this to a function, and I want double-quotes around the value of the variable below, example $var = "New York" (note the quotes)

   $fq.=" + area:$state";

So when I echo $state I want开发者_如何转开发 double quotes around it, how can I do this?

Thanks


You can write it like this:

$fq .= " + area:\"$state\"";

The backslash escapes special characters(like newline, tabs or quotes) in double quoted strings.


$var = '"New York"';
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号