note 110829 added to language.operators.logical

From: Date: Wed, 12 Dec 2012 14:35:46 +0000
Subject: note 110829 added to language.operators.logical
Groups: php.notes 
Request: Send a blank email to php-notes+get-192489@lists.php.net to get a copy of this message
Unlike in C/C++ the invertor (Not) in PHP assumes a string: <?php $a = 1; $t = !$a; var_dump($t); ?> The above example will output: string(0) => "" To approach the C/C++ handling, this can be solved as follows: <?php $a = 1; (int) $t = !$a; var_dump($t); (bool) $u = !a; var_dump($u); ?> The above example will output: int(0) bool(false) ---- Server IP: 69.147.83.199 Probable Submitter: 72.52.91.2 (proxied: 84.27.119.117) ---- Manual Page -- http://php.net/manual/en/language.operators.logical.php Edit -- https://master.php.net/note/edit/110829 Del: integrated -- https://master.php.net/note/delete/110829/integrated Del: useless -- https://master.php.net/note/delete/110829/useless Del: bad code -- https://master.php.net/note/delete/110829/bad+code Del: spam -- https://master.php.net/note/delete/110829/spam Del: non-english -- https://master.php.net/note/delete/110829/non-english Del: in docs -- https://master.php.net/note/delete/110829/in+docs Del: other reasons-- https://master.php.net/note/delete/110829 Reject -- https://master.php.net/note/reject/110829 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#192489) next »