它是关于在 mysql 表中插入数据时 php 中的语法
为什么使用这种语法:
mysql_query("INSERT INTO users (username, password, email, hash) VALUES(
'". mysql_escape_string($name) ."',
'". mysql_escape_string(md5($password)) ."',
'". mysql_escape_string($email) ."',
'". mysql_escape_string($hash) ."') ") or die(mysql_error());
我对 mysql_escape_string 函数没有任何困惑,但是为什么 mysql_escape_string($name)
包含在两个点中:。 mysql_escape_string($name) .
然后用双引号括起来:". mysql_escape_string($name) ."
最后整个内容用单引号括起来:'" .mysql_escape_string($name) ."'
我通过以下 Web 资源获得了此表单:http://net.tutsplus.com/tutorials/php/how-to-implement-email-verification-for-new-members/
.. .它是一个php电子邮件验证程序。
Why is this syntax used:
mysql_query("INSERT INTO users (username, password, email, hash) VALUES(
'". mysql_escape_string($name) ."',
'". mysql_escape_string(md5($password)) ."',
'". mysql_escape_string($email) ."',
'". mysql_escape_string($hash) ."') ") or die(mysql_error());
I do not have any confusion about mysql_escape_string , function, however why is mysql_escape_string($name)
, enclosed within two dots:. mysql_escape_string($name) .
then it is enclosed within double quotes:". mysql_escape_string($name) ."
lastly the whole thing is enclosed within a single quote :'". mysql_escape_string($name) ."'
I got this form the following web resource: http://net.tutsplus.com/tutorials/php/how-to-implement-email-verification-for-new-members/
...Its a php email verification program.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
点 (.) 是字符串连接的粘合剂。它也用于分隔变量:
双引号是我们所说的字符串的方式:
被认为是整数,
被认为是字符串。
最后,单引号是 mysql 语法的一部分,它要求字符串被 ' 包围。
The dot (.) is the glue for string concatenation. It is used also for separating variables:
The double quotes is the way we say that that is a string:
is considered an integer,
is considered a string.
And finally the single quote is a part of the mysql syntax that requires the strings to be surrounded by '.
点运算符是字符串连接的粘合剂。双引号代表字符串的开头和结尾。 “字符串1”。 “字符串2”。 “string3”相当于:“string1string2string3”。
The dot operator is the glue for string concatenation. The double quotes represent the start and end of a string. "string1" . "string2" . "string3" would be equivilant to: "string1string2string3".
(.) 将整个字符串连接在一起。请参阅此处 字符串运算符
如果您回显查询,它会看起来像这样像这样。
The (.) is concatenating the whole string together. see here string operators
If you echo'ed the query it would look something like this.