Tuesday, 15 June 2010

PHP expression a || b = c -



PHP expression a || b = c -

i don't understand next expression, , how works.

a || b = c

i guess check if a true, , if it's not, 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 , fact result of look ignored:

if (!$id) { $data['created'] = $now; }

see also: logical operators

php

No comments:

Post a Comment