note 79281 added to language.operators.logical

From: Date: Mon, 19 Nov 2007 16:00:01 +0000
Subject: note 79281 added to language.operators.logical
Groups: php.notes 
Request: Send a blank email to php-notes+get-132405@lists.php.net to get a copy of this message
and, or and xor can be used as conditional constructs: <?php // do_that() is executed only if do_this() returns false if($something) do_this() or do_that(); // $b is assigned to $b, do_that() is executed if $b is false if($something) $a = $b or do_that(); // do_that() is executed only if do_this() returns true if($something) do_this() and do_that(); // $b is assigned to $b, do_that() is executed if $b is true if($something) $a = $b and do_that(); // both do_that() and do_this() are executed.. if($something) do_this() xor do_that(); // .. so the behaviour is same as: if($something) { do_this(); do_that(); } ?> for understanding what happens if $b is NULL or do_this() returns NULL, read the avbentem's comment on NULL type. generaly speaking, NULL is threated like false in most cases. ---- Server IP: 69.147.83.197 Probable Submitter: 213.210.151.158 ---- Manual Page -- http://www.php.net/manual/en/language.operators.logical.php Edit -- https://master.php.net/note/edit/79281 Del: integrated -- https://master.php.net/note/delete/79281/integrated Del: useless -- https://master.php.net/note/delete/79281/useless Del: bad code -- https://master.php.net/note/delete/79281/bad+code Del: spam -- https://master.php.net/note/delete/79281/spam Del: non-english -- https://master.php.net/note/delete/79281/non-english Del: in docs -- https://master.php.net/note/delete/79281/in+docs Del: other reasons-- https://master.php.net/note/delete/79281 Reject -- https://master.php.net/note/reject/79281 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#132405) next »