note 119727 added to language.operators.logical

From: Date: Thu, 11 Aug 2016 16:05:06 +0000
Subject: note 119727 added to language.operators.logical
Groups: php.notes 
Request: Send a blank email to php-notes+get-206263@lists.php.net to get a copy of this message
I had problem in my app, where I (with nick Soaku) had access to admin options. But everyone logged in also had it... I found out the problem soon. Correctly, I had this in the code: <?php if (!$user->username == "Soaku") { # [...] } ?> I thought it would return the reversed result of $user->username == "Soaku", but it always returned false for logged in people. To prevent this, instead of the previous example, always do this: <?php if (!($user->username == "Soaku")) { # [...] } ?> or this: <?php if ($user->username != "Soaku") { # [...] } ?> ---- Server IP: 72.52.91.14 Probable Submitter: 91.231.24.149 ---- Manual Page -- http://php.net/manual/en/language.operators.logical.php Edit -- https://master.php.net/note/edit/119727 Del: integrated -- https://master.php.net/note/delete/119727/integrated Del: useless -- https://master.php.net/note/delete/119727/useless Del: bad code -- https://master.php.net/note/delete/119727/bad+code Del: spam -- https://master.php.net/note/delete/119727/spam Del: non-english -- https://master.php.net/note/delete/119727/non-english Del: in docs -- https://master.php.net/note/delete/119727/in+docs Del: other reasons-- https://master.php.net/note/delete/119727 Reject -- https://master.php.net/note/reject/119727 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#206263) next »