|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2003-11-04 16:08 UTC] iliaa@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Fri Dec 05 03:00:01 2025 UTC |
Description: ------------ Result of 'and' operator not what is expected. 1 and 0 and 1 => 1? Should be 0. See attached code sample. '&&' operator does function correctly however. Reproduce code: --------------- $primary_err_valid = (($_POST['primary_err'] != "category") and ($_POST['primary_err'] != "separator")); $secondary_err_valid = (($_POST['secondary_err'] != "category") and ($_POST['secondary_err'] != "separator")); $tertiary_err_valid = (($_POST['tertiary_err'] != "category") and ($_POST['tertiary_err'] != "separator")); $error_valid = ($primary_err_valid) and ($secondary_err_valid) and ($tertiary_err_valid); echo "Pri: $primary_err_valid <br>"; echo "Sec: $secondary_err_valid <br>"; echo "Tri: $tertiary_err_valid <br>"; echo "Total Error: $error_valid <br>"; Expected result: ---------------- Pri: 1 Sec: Tri: 1 Total Error: Actual result: -------------- Pri: 1 Sec: Tri: 1 Total Error: 1