Ask a Question related to PHP Notes, Design and Development.
-
didou@php.net #1
note 33937 deleted from language.operators.comparison by didou
Note Submitter: [email]kari_hre@hotmail.com[/email]
----
The ternary operator with many conditions has always confused me so I sat down and played with it for a while. Here are the results.
This:
echo ($var1 == 1) ? ($var2 == 2) ? ($var3 == 3) ? 'a' : 'b' : 'c' : 'd';
works just as:
if ($var1 == 1) {
if ($var2 == 2) {
if ($var3 == 3) {
echo 'a';
} else {
echo 'b';
}
} else {
echo 'c';
}
} else {
echo 'd';
}
Hope this will clear up some confusion!
didou@php.net Guest
-
note 33903 added to language.operators.arithmetic
Since Modulo is defined, there is a way to define integer division such that it STAYS in integer mode and you never have to worry about float... -
note 33787 added to language.operators.comparison
dragon_rage4's code has a mistake: "if ($myVar == $myVar++)" will always evaluate to true, so the second case will also print "They are equal". ... -
note 33716 added to language.operators.errorcontrol
if you create a new variable by assigning to it the error suppressed value of an unset variable, the new variable will be set, with a value of (I... -
note 21357 deleted from function.is-a by didou
Note Submitter: krisher@oswego.edu ---- Any implementation of is_a that relies on empty() to test whether the object parameter is empty will... -
note 29986 deleted from ref.objaggregation by didou
Note Submitter: galland@appli-box.com ---- bugfree object association example : <?php /** * corrected example of object association ...



Reply With Quote

