I don't really understand the following expression, what it does and how it works.
a || b = c
I guess it check if a is true, and if it's not, it run b = c?
Exemple of application:
$id || $data['created'] = $now
I don't really understand the following expression, what it does and how it works.
a || b = c
I guess it check if a is true, and if it's not, it run b = c?
Exemple of application:
$id || $data['created'] = $now
It's short for:
($id == true) || (($data['created'] = $now) == true)
Factoring in short circuit logic and the fact that the result of the expression itself is ignored:
if (!$id) {
$data['created'] = $now;
}
See also: Logical operators