Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:10327 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 72081 invoked by uid 1010); 8 Jun 2004 18:07:03 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 72057 invoked from network); 8 Jun 2004 18:07:03 -0000 Received: from unknown (HELO hoggle.dreamhost.com) (66.33.197.5) by pb1.pair.com with SMTP; 8 Jun 2004 18:07:03 -0000 Received: from [192.168.0.152] (mail.appliedsec.com [69.17.65.231]) by hoggle.dreamhost.com (Postfix) with ESMTP id 40D8253831; Tue, 8 Jun 2004 11:07:02 -0700 (PDT) Message-ID: <40C60042.5000608@velum.net> Date: Tue, 08 Jun 2004 14:06:58 -0400 User-Agent: Mozilla Thunderbird 0.6 (Windows/20040502) X-Accept-Language: en-us, en MIME-Version: 1.0 To: Robert Janeczek Cc: internals@lists.php.net References: <20040608175939.47739.qmail@pb1.pair.com> In-Reply-To: <20040608175939.47739.qmail@pb1.pair.com> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: 'false' - boolean interpratation From: hans@velum.net (Hans Lellelid) Robert Janeczek wrote: > is there any way that string 'false' (and its variations with capital > letters) could be interpeted as boolean of value false? i have xml > configuration file that has some switches (true/false) in it. when i use > this values in functions that require booleans i get true every time (as > string isn`t empty) :/ i hoped that at least with explicit type cast i could > go around this problem, but i didn`t help. > how about adding this special case to conversion rules? creating if`s around > such code doesn`t make me happy at all :] IMO better as userland function/method (this is extract from a Phing class): ... private static $TRUE_VALUES = array("on", "true", "t", "yes"); ... public function booleanValue($s) { if (is_bool($s)) { return $s; // it's already boolean (not a string) } // otherwise assume it's something like "true" or "t" $trimmed = strtolower(trim($s)); return in_array($trimmed, self::$TRUE_VALUES); } Hans