` 和 ' 之间有什么区别?在编程方面,例如 MySQL 和 shell
phpMySQL 使用反引号 ` 来包围列名,我刚刚看到人们在 shell 脚本中使用反引号。
如果他们使用 ' ,那是一样的吗?
phpMySQL use backticks ` to surround column names, and I've just see people use backticks in shell scripts.
Is that the same if they use ' ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
在 MySQL 中,反引号可用于括起保留字的表名和列名,如下所示:
单引号仅表示字符串常量:
在 shell 中,反引号可让您将一个命令的输出用作另一个命令的参数:
将执行
date
并将其输出用作echo
的参数。单引号允许您在参数内使用空格、美元符号和反斜杠:
将按原样输出字符串
$HOSTNAME
,两者都会输出环境变量
HOSTNAME
的值。In
MySQL
, backticks could be used to enclose table and column names which are reserved words, like this:Single quotes just denote a string constant:
In shells, backticks let you use the output of one command as an argument to another command:
will execute
date
and use its output as an argument toecho
.Single quotes let you use whitespaces, dollar signs and backslashes inside the arguments:
will output the string
$HOSTNAME
as it is,both will output the value of the environment variable
HOSTNAME
.在 shell 中,一对反引号将被它们所包含的命令的 (stdout) 输出替换。
In shell, a pair of backticks will be replaced by the (stdout) output of the command they enclose.