What does it do

$ top + = $ i? 12-0;

+4
source share
7 answers

If $i is

  • set
  • not false
  • not null

increment $top by twelve; otherwise, by zero, implicitly turning $top ( not $i ) into a numerical variable if it is not already one.

+12
source

If $i has the value set (a non-empty / empty value means that the condition resolves to true), then 12 is added to $top and 0 otherwise.

This is basically a reduction:

 if ($i) { $top += 12; } else { $top += 0; } 

This is called the Ternary statement.

+11
source

Abbreviation for:

 if ($i) { $top += 12; } 
+4
source

If $ i is true (for example, not zero or an empty string), then 12 is added to $ top. Otherwise, nothing is added to $ top.

It is equivalent

 if($i) $top = top + 12; 
+2
source

Increase the value of $top by 12 if $i has a true Boolean value (i.e. $i = 1 , $i = true , etc.) or 0 if not.

http://www.php.net/manual/en/language.operators.assignment.php

Ternary operator

+1
source

$ i? 12-0 is the expression for β€œtranscripts”. In this case, $ i is evaluated as an expression. If the expression is true, then 12 is used as the r-value in the addition assignment expression. If $ i evaluates to false, then 0 is used as the r-value.

0
source

Source: https://habr.com/ru/post/1309591/


All Articles