脚本语言中的美元符号 - 为什么? [英] Dollar notation in script languages - why?

查看:55
本文介绍了脚本语言中的美元符号 - 为什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有谁知道某些脚本语言(即 PHP 或 Perl)中美元变量表示法"背后的实际原因是什么?Python 创建者没有发现 $variable 有用,我也没有.为什么 PHP 和 Perl 强迫我如此频繁地按 shift-4?

(好吧,在 Perl 中你可以通过区分 $scalar@array%hash 以某种方式解释它,但它仍然可以成功避免在那里,类型不需要显式)

解决方案

我不知道这是否是主要原因,但如果 PHP 没有带有标识标记的变量,则以下情况是不可能的.

>

echo "欢迎回来 $name,我们最后一次见到你是在 $date";

更新:

它还创建了一个叫做变量的东西.不过,可变变量的用处值得商榷,我不建议任何人经常使用它们.

Does anyone know, what is the actual reason behind "dollar variable notation" in some of the scripting languages, i.e. PHP or Perl? Python creators did not find $variable useful, neither do I. Why does PHP and Perl force me to press shift-4 so often?

(OK, in Perl you can somehow explain it with distinguishing $scalar, @array and %hash but still it could be successfully avoided there, type does not need to be explicit)

解决方案

I don't know if this is the main reason, but if PHP did not have variables with an identifying marker, the following would not be possible.

echo "Welcome back $name, we last saw you on $date";

Update:

It also creates something called a variable variable possible. The usefulness of a variable variable is debatable though, and I wouldn't recommend anyone making regular use of them.

这篇关于脚本语言中的美元符号 - 为什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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