Note that there are some explanatory texts on larger screens.

plurals
  1. POWhat is this assignment construct called? And can you do it in Php?
    primarykey
    data
    text
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. COThanks all for your answers, had to pick one but all are correct. Of course it is the logical OR :) Perhaps the word "pattern" would have better conveyed my puzzled observation. It is so handy that I thought people may have put a name on it. To me this is almost like a pattern. It is very readable and intuitively easy to understand. It is almost like reading plain english. The trick though as observed by Kos, is that it is entirely dependent on how the language evaluates the logical OR. Shame.
      singulars
      1. This table or related slice is empty.
    2. COAnother example. It is often useful to make sure that a non-acceptable result of a function returns false (or null, etc). But maybe the code gives a 0 or null (perhaps another routine you call from a underlying framework). So you end up with something like `return var_result || false;` If the result of the code is truthy it is returned as is, otherwise you are sure to return false as per documentation, or for consistency in your api. But yeah, it can be done with a ternary operator, only *far less cool*.
      singulars
      1. This table or related slice is empty.
    3. COpossible duplicate of [Does PHP have a default assignment idiom like perl?](http://stackoverflow.com/questions/2958630/does-php-have-a-default-assignment-idiom-like-perl)
      singulars
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload