What do the '&=' and '=&' operators do?

Finding the answer to this is turning out to be much more difficult than I would have thought. Since I don't have a clue what you'd call this, it's hard to run a Google search since it will ignore those characters. I tried browsing the PHP Assignment Operators page, and even the other operators pages, and found nothing that told me exactly what they do. I don't just want to gu

'&='和'=&'运算符是做什么的?

找到答案是比我想象的要困难得多。 由于我不知道你会怎么称呼它,因此很难运行Google搜索,因为它会忽略这些字符。 我尝试浏览PHP Assignment Operators页面,甚至浏览其他操作页面,但没有发现任何内容告诉我他们的确做了什么。 我不只是想根据我使用它的单个函数来猜测。 那么'&='和'=&'运营商究竟做了什么? 我所知道的是它设置了一个变量,这将是'='部分,所以我真的需要知道'&'

What do the "=&" and "&=" operators in PHP mean?

What do "=&" / "&=" operators in PHP mean? Where can I read information about them? Searching Google doesn't help. $a &= $b is short for $a = $a & $b which is the bitwise-and operator. $a =& $b assigns $a as a reference to $b. =& $a =& $b turns $a into an alias for $b . If the value or reference of $a is changed, the value or referen

PHP中的“=&”和“&=”运算符是什么意思?

PHP中的“=&”/“&=”运算符是什么意思? 我在哪里可以阅读关于他们的信息? 搜索谷歌没有帮助。 $a &= $b是$a = $a & $b简称,它是按位运算符。 $a =& $b将$a =& $b分配给$ b的引用。 = $a =& $b将$a转换为$b的别名。 如果$a的值或引用发生更改, $b的值或引用将相应更改。 这与“指向同一地点”的对象不同:我可以做$c = $d = new AnObject( ),并且这两个变量都指向相同的地方; 然而,改变其

Reference assignment operator in PHP, =&

What does the =& (equals-ampersand) assignment operator do in PHP? Is it deprecated? It's not deprecated and is unlikely to be. It's the standard way to, for example, make part of one array or object mirror changes made to another, instead of copying the existing data. It's called assignment by reference , which, to quote the manual, "means that both variables end up p

PHP中的引用赋值运算符,=&

在PHP中, =& (等号&符号)赋值操作符是做什么的? 它是否被弃用? 它不被弃用,不太可能。 例如,这是一种标准方式,可以将一个数组的一部分或对象镜像更改为另一个,而不是复制现有数据。 这就是所谓的按引用分配,引用手册,“这意味着两个变量最终指向相同的数据,而且任何地方都不会复制任何内容”。 在PHP 5中,唯一被=&弃用的是“通过引用分配new的结果”,这可能是任何混淆的根源。 new通过引用自动分配

Is there ever a need to use ampersand in front of an object?

因为对象现在默认通过引用传递,那么当&$obj有意义时,是否有一些特殊情况? Objects use a different reference mechanism. &$object is more a reference of a reference. You can't really compare them both. See Objects and references: A PHP reference is an alias, which allows two different variables to write to the same value. As of PHP 5, an object variable doesn't contain the objec

有没有必要在对象前面使用&符号?

因为对象现在默认通过引用传递,那么当&$obj有意义时,是否有一些特殊情况? 对象使用不同的引用机制。 &$object更多是参考的参考。 你无法真正比​​较他们两个。 请参阅对象和参考: PHP引用是一个别名,它允许两个不同的变量写入相同的值。 从PHP 5开始,对象变量不再包含对象本身的值。 它只包含一个对象标识符,它允许对象访问器找到实际的对象。 当一个对象被参数发送,返回或分配给另一个变量时,不同的变

When should I use a bitwise operator?

I read the following Stack Overflow questions, and I understand the differences between bitwise and logical. Difference between & and && in PHP Reference - What does this symbol mean in PHP? However, none of them explains when I should use bitwise or logical. When should I use bitwise operators rather than logical ones and vice versa? In which situation do I need to compare

什么时候应该使用按位运算符?

我阅读了以下堆栈溢出问题,并了解了按位和逻辑之间的差异。 PHP中&和&&的区别 参考 - 这个符号在PHP中的含义是什么? 但是,它们中的任何一个都不能解释什么时候应该使用按位或逻辑。 什么时候应该使用按位运算符而不是逻辑运算符,反之亦然? 在哪种情况下我需要逐点比较? 我不是在问这些差异,但是我在问你什么时候需要使用按位运算符。 按位| 和&和逻辑|| 和&&完全不同。 按位运算

What does & in &2 mean in PHP?

In the last line of the following code, it has &2, if($page['special']&2). What does & mean? if(isset($_REQUEST['id']))$id=(int)$_REQUEST['id']; else $id=0; if($id){ // check that page exists $page=dbRow("SELECT * FROM pages WHERE id=$id"); if($page!==false){ $page_vars=json_decode($page['vars'],true); $edit=true; } } if(!isset($edit)){ $pare

&in&2在PHP中意味着什么?

在以下代码的最后一行中,它有&2, if($page['special']&2). 这是什么意思? if(isset($_REQUEST['id']))$id=(int)$_REQUEST['id']; else $id=0; if($id){ // check that page exists $page=dbRow("SELECT * FROM pages WHERE id=$id"); if($page!==false){ $page_vars=json_decode($page['vars'],true); $edit=true; } } if(!isset($edit)){ $parent=isset($_REQUEST['parent

How does the "&" operator work in a PHP function?

Please see this code: function addCounter(&$userInfoArray) { $userInfoArray['counter']++; return $userInfoArray['counter']; } $userInfoArray = array('id' => 'foo', 'name' => 'fooName', 'counter' => 10); $nowCounter = addCounter($userInfoArray); echo($userInfoArray['counter']); This will show 11. But! If you remove "&"operator in the function parameter, th

“&”运算符如何在PHP函数中工作?

请看这个代码: function addCounter(&$userInfoArray) { $userInfoArray['counter']++; return $userInfoArray['counter']; } $userInfoArray = array('id' => 'foo', 'name' => 'fooName', 'counter' => 10); $nowCounter = addCounter($userInfoArray); echo($userInfoArray['counter']); 这将显示11。 但! 如果在函数参数中删除“&”运算符,结果将为10。 这是怎么回事? &运算符告诉PH

What does this signature mean (&) in PHP?

Consider: public function & get($name, $default = null) Why & ? In PHP's syntax, this means that the function returns a reference instead of a value. For example: <?php $foo = 'foo'; function & get_foo_ref () { global $foo; return $foo; } // Get the reference to variable $foo stored into $bar $bar = & get_foo_ref(); $bar =

这个签名在PHP中意味着什么(&)?

考虑: public function & get($name, $default = null) 为什么& ? 在PHP的语法中,这意味着该函数返回一个引用而不是一个值。 例如: <?php $foo = 'foo'; function & get_foo_ref () { global $foo; return $foo; } // Get the reference to variable $foo stored into $bar $bar = & get_foo_ref(); $bar = 'bar'; echo $foo; // Outputs 'bar'

What does the "&" sign mean in PHP?

This question already has an answer here: Reference — What does this symbol mean in PHP? 18 answers This will force the variable to be passed by reference. Normally, a hard copy would be created for simple types. This can come handy for large strings (performance gain) or if you want to manipulate the variable without using the return statement, eg: $a = 1; function inc(&$input) {

PHP中“&”符号的含义是什么?

这个问题在这里已经有了答案: 参考 - 这个符号在PHP中的含义是什么? 18个答案 这将强制变量通过引用传递。 通常,为简单类型创建一个硬拷贝。 这对于大型字符串(性能增益)来说可能非常方便,或者如果您想在不使用return语句的情况下操作变量,例如: $a = 1; function inc(&$input) { $input++; } inc($a); echo $a; // 2 对象将自动通过引用传递。 如果你想处理复制到一个函数,使用 clone $object;

What does "&" mean in this case?

I know that it's creating a reference in other cases. But what happens here? $crawler = &new MyCrawler(); It creates an instance of MyCrawler and passes the reference for that instance into $crawler. In PHP5 this is assumed so the use of the & is deprecated. See Object References (the Ampersand). 根据PHP文档已弃用

在这种情况下,“&”是什么意思?

我知道这是在其他情况下创建一个参考。 但是这里发生了什么? $crawler = &new MyCrawler(); 它创建一个MyCrawler的实例,并将该实例的引用传递给$ crawler。 在PHP5中,这是假设的,因此不推荐使用& 。 请参阅对象引用(和符号)。 根据PHP文档已弃用