{$var} 和 $var 有什么区别? [英] Whats the difference between {$var} and $var?

查看:45
本文介绍了{$var} 和 $var 有什么区别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道何时以及为什么应该使用 {$var}

I would like to know when and why should I use {$var}

echo "This is a test using {$var}";

以及何时(以及为什么)我应该使用简单的形式 $var

and when (and why) should I use the simple form $var

echo "This is a test using $var";

推荐答案

当 a) 不访问对象或数组的值,以及 b) 变量名后面没有可能被解释为的字符时,您将使用后者一部分.

You would use the latter when a) not accessing an object or array for the value, and b) no characters follow the variable name that could possibly be interpreted as part of it.

这篇关于{$var} 和 $var 有什么区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆