What does a . (dot) do in PHP?

下面的命令在PHP中做了什么? . $string // ($string is something which i declared in the program) On its own, that does nothing at all (it's not valid syntax). However, if you have something like this: <?php $string1 = "Hello "; $string2 = "world!"; $string = $string1 . $string2; echo $string; ?> You will see Hello world! . The . is the string concatenation operator. Taken al

什么是。 (点)在PHP中做?

下面的命令在PHP中做了什么? . $string // ($string is something which i declared in the program) 就其本身而言,它什么也不做(这不是有效的语法)。 但是,如果你有这样的事情: <?php $string1 = "Hello "; $string2 = "world!"; $string = $string1 . $string2; echo $string; ?> 你会看到Hello world! 。 这个. 是字符串连接运算符。 单独考虑,这是一个语法错误。 点. 是将其参数转换为字符串并

Difference between period and comma when concatenating with echo versus return?

I just found that this will work: echo $value , " contiue"; but this does not: return $value , " contiue"; While "." Works in both. What is the difference between a period and a comma here? return does only allow one single expression. But echo allows a list of expressions where each expression is separated by a comma. But note that since echo is not a function but a special

与echo和return连接时的句号和逗号之间的区别?

我只是发现这将起作用: echo $value , " contiue"; 但是这不: return $value , " contiue"; 虽然“。” 适用于两者。 这里的时间和逗号之间有什么区别? return只允许一个表达式。 但是, echo允许使用逗号分隔每个表达式的表达式列表。 但请注意,由于echo不是函数,而是特殊的语言结构,因此将表达式列表包装在括号内是非法的。 的. 是PHP中的连接运算符,用于将两个字符串放在一起。 逗号可以用于多个输入来回

To understand a line of PHP

This question already has an answer here: Reference — What does this symbol mean in PHP? 18 answers 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" In your case $query = "UPDATE authors SET aut

了解一行PHP

这个问题在这里已经有了答案: 参考 - 这个符号在PHP中的含义是什么? 18个答案 这是连接赋值运算符。 它将连接或添加到字符串的末尾。 所以: $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=L

What is the difference between .= and += in PHP?

PHP中的。=和+ =有什么区别? Quite simply, "+=" is a numeric operator and ".=" is a string operator. Consider this example: $a = 'this is a '; $a += 'test'; This is like writing: $a = 'this' + 'test'; The "+" or "+=" operator first converts the values to integers (and all strings evaluate to zero when cast to ints) and then adds them, so you get 0. I

在PHP中。=和+ =有什么区别?

PHP中的。=和+ =有什么区别? 很简单,“+ =”是一个数字运算符,“。=”是一个字符串运算符。 考虑这个例子: $a = 'this is a '; $a += 'test'; 这就像写作: $a = 'this' + 'test'; “+”或“+ =”运算符首先将值转换为整数(并且所有字符串在转换为整数时计算为零),然后将它们相加,所以得到0。 如果你这样做: $a = 10; $a .= 5; 这和写作一样: $a = 10 . 5; 由于“。” 运算符是一个字符串运算符,它首先将值转换为

Understanding Incrementing

For example this: var a = 123; var b = a++; now a contains 124 and b contains 123 I understand that b is taking the value of a and then a is being incremented. However, I don't understand why this is so. The principal reason for why the creators of JavaScript would want this. What is the advantage to this other than confusing newbies? That's why it's called the "post-inc

了解增量

例如: var a = 123; var b = a++; 现在a包含124和b包含123 我知道b正在取a的值,然后a就会递增。 但是,我不明白为什么会这样。 JavaScript创作者为什么会这么想的主要原因。 除了混淆新手之外,其他的优势是什么? 这就是为什么它被称为“后递增算子”。 从本质上讲,一切都是一个表达结果的价值。 a + 1是一个导致值为124的表达式。如果将其赋值给b并且b = a + 1 ,则b的值为124.如果不将结果赋值给任何值,则a + 1

= 1` in my PHP document mean?

I have the following variable defined in a PHP document I am working with, and I'm unsure what it means. The PHP $page -= 1; The part I am unsure of is the -= Thanks! The -= operator is shorthand for subtracting a value from the variable: $x -= 1; $x = $x - 1; Here's some of the other ones: $x += 1; ( $x = $x + 1 ) $x -= 1; ( $x = $x - 1 ) $x *= 1; ( $x = $x * 1 ) $x /=

= 1`在我的PHP文件中是什么意思?

我在我正在使用的PHP文档中定义了以下变量,我不确定它的含义。 PHP $page -= 1; 我不确定的部分是-= 谢谢! -=运算符是从变量中减去一个值的简写形式: $x -= 1; $x = $x - 1; 以下是其他一些: $x += 1; ( $x = $x + 1 ) $x -= 1; ( $x = $x - 1 ) $x *= 1; ( $x = $x * 1 ) $x /= 1; ( $x = $x / 1 ) 这是保存输入的简写。 它的效果是理想的 $page = $page - 1; -=运算符是一个组合运算和赋值

What is += used for?

I think this is a dumb question but I could not find it on php. Why is a + with the = in the following code: function calculateRanking() { $created = $this->getCreated(); $diff = $this->getTimeDifference($created, date('F d, Y h:i:s A')); $time = $diff['days'] * 24; $time += $diff['hours']; $time += ($diff['minutes'] / 60); $time += (($diff['seconds'] / 60)/60);

什么是+ =用于?

我认为这是一个愚蠢的问题,但我无法在php上找到它。 为什么在下面的代码中使用=来代替=: function calculateRanking() { $created = $this->getCreated(); $diff = $this->getTimeDifference($created, date('F d, Y h:i:s A')); $time = $diff['days'] * 24; $time += $diff['hours']; $time += ($diff['minutes'] / 60); $time += (($diff['seconds'] / 60)/60); $base = $time + 2;

+ operator for array in PHP?

$test = array('hi'); $test += array('test','oh'); var_dump($test); 是什么+意味着在PHP数组? Quoting from the PHP Manual on Language Operators The + operator returns the right-hand array appended to the left-hand array; for keys that exist in both arrays, the elements from the left-hand array will be used, and the matching elements from the right-hand array will be ignored. So if you do $arr

PHP中的数组运算符?

$test = array('hi'); $test += array('test','oh'); var_dump($test); 是什么+意味着在PHP数组? 从PHP语言操作员手册引用 +运算符返回附加到左侧数组的右侧数组; 对于这两个数组中存在的键,将使用左侧数组中的元素,并忽略右侧数组中的匹配元素。 所以,如果你这样做 $array1 = ['one', 'two', 'foo' => 'bar']; $array2 = ['three', 'four', 'five', 'foo' => 'baz']; print_r($array1 + $array2);

What does this ~ operator mean here?

Example: set_error_handler(array($this, 'handleError'), E_ALL & ~E_STRICT & ~E_WARNING & ~E_NOTICE); what does that suppose to mean? It is the bitwise not operator (also called "complement"). That is the bits set in ~ $a are those that are not set in $a . So then E_ALL & ~E_STRICT & ~E_WARNING & ~E_NOTICE is the bits set in E_ALL and those not set in E_S

这个〜操作符在这里表示什么?

例: set_error_handler(array($this, 'handleError'), E_ALL & ~E_STRICT & ~E_WARNING & ~E_NOTICE); 这是什么意思? 它是按位不操作符(也称为“补充”)。 这就是~ $a中设置的那些位未在$a设置$a 。 那么 E_ALL & ~E_STRICT & ~E_WARNING & ~E_NOTICE 是在E_ALL设置的位和在E_STRICT , E_WARNING和E_NOTICE未设置的位。 这基本上说,除严格,警告和通知错误之外的所有错误。 它是按位运

The behaviour of the or operator in PHP

I'm trying to understand the behavior of or operator. Please see the below examples: $e = false || true; var_dump($e); Output is as expected: bool(true); $f = false or true; var_dump($f); Output is as expected: bool(false) . I understood this in a way that the = has a higher precedence than the Or , so that's why the $f is assigned to false . But the below code works quite opposit

PHP中的or运算符的行为

我试图了解or操作员的行为。 请看下面的例子: $e = false || true; var_dump($e); 输出如预期: bool(true); $f = false or true; var_dump($f); 输出如预期: bool(false) 。 我以某种方式理解了这一点,即=具有比Or更高的优先级,所以这就是$f被赋予false 。 但下面的代码与我的想法完全相反。 我认为$foo将被分配到5 ,然后与自身进行比较。 但是$foo只有在$foo被设置的情况下才会被赋值,这意味着它正在检查$foo