了解一行PHP [英] To understand a line of PHP
本文介绍了了解一行PHP的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
以下几行是什么意思,尤其是运算符.=
?
What does the following line mean, particularly the operator .=
?
$query .= "UPDATE authors SET author=LOWER(author) WHERE id=2;";
在代码
<?php
$conn = pg_pconnect("dbname=publisher");
// these statements will be executed as one transaction
$query = "UPDATE authors SET author=UPPER(author) WHERE id=1;";
$query .= "UPDATE authors SET author=LOWER(author) WHERE id=2;";
pg_query($conn, $query);
?>
它似乎构成了某种数组,使得最后一个命令首先处理第一个查询,然后处理第二个查询.
It seems to make some sort of array such that the last command processes first the first query and then the second.
推荐答案
这是串联分配运算符.它将串联或添加到字符串的末尾.所以:
This is the concatenate assignment operator. It will concatenate or add to the end of the string. So:
$a = "Hi!";
$a .= " I";
$a .= " love";
$a .= " StackOverflow";
$a .= " a";
$a .= " lot";
echo $a; // echos "Hi! I love StackOverflow a lot"
以您的情况
$query = "UPDATE authors SET author=UPPER(author) WHERE id=1;";
$query .= "UPDATE authors SET author=LOWER(author) WHERE id=2;";
echo $query;
/* echos "UPDATE authors SET author=UPPER(author) WHERE id=1; UPDATE authors SET author=LOWER(author) WHERE id=2; */
这篇关于了解一行PHP的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文