markdown 与Jason就PHP报价进行问答

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了markdown 与Jason就PHP报价进行问答相关的知识,希望对你有一定的参考价值。

Why do both of these work? Why does one need single quotes around the array key and the other doesn't?

```
echo '<li><a href="' . $item['slug'] . '">' . $item['title'] . '</a></li>';

echo "<li><a href=\"$item[slug]\">$item[title]</a></li>";
```

On the other hand, this doesn't work:
```
echo '<li><a href="$item[slug]">$item[title]</a></li>';
```
(it displays as $item[title] )

----

Items in single quotes get output verbatim, unprocessed
Items in double quotes get processed

If you use curly braces, your editor will make it clear that the thing is a variable

```echo "<li><a href=\"{$item['slug']}\">{$item['title']}</a></li>"; ```

Jason likes to use:
```echo "<li><a href='{$item['slug']}'>{$item['title']}</a></li>"; ```

If not including variables, definitely use single quotes all the time.

以上是关于markdown 与Jason就PHP报价进行问答的主要内容,如果未能解决你的问题,请参考以下文章

markdown 编程报价(来源:http://www.defprogramming.com)

markdown 来自Cal Newport的深度工作书的报价

markdown 思考投资组合问答,提示和技巧

CSDN问答使用体验产品BUG和改进建议

问答项目---账号密码异步校验后进行PHP校验

使用 Steam API 发送 Steam 报价