php - !$variable = $variable inside if -
i gnawing on basics of php socket servers , client here.
then stumbled upon these lines (excerpt above links first example, happens inside while
):
if (false === ($buf = socket_read($msgsock, 2048, php_normal_read))) { echo "socket_read() failed: reason: " . socket_strerror(socket_last_error($msgsock)) . "\n"; break 2; } if (!$buf = trim($buf)) { continue; }
i'm okay reading part, , closing connection in case there error reading.
but next if
driving me nuts.
firstly, i'm confused how 1 may , need assign value boolean.
secondly, have trouble understanding whole expression altogether.
could please explain happens inside if, , how applies server context?
p.s. please excuse me if question isn't asked. i'm confused happens there , have no idea ask for.
with statement, there's no assignment boolean. we're comparing type of false
, value of false
(true false, not merely 0). can read here
if (false === ($buf = socket_read($msgsock, 2048, php_normal_read)))
then
if (!$buf = trim($buf)) { continue; }
this same as
$buf = trim($buf); if ($buf == false) { continue; }
so, explain original:
// assignment happens first , we're checking boolean value if (!$buf = trim($buf))
Comments
Post a Comment