Re: [PHP] "My truth comes out" [1]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Because it is an if statement, just in a different form, and preg_match is more computational expensive than a direct string comparison.

Thanks,
Ash
http://www.ashleysheridan.co.uk

----- Reply message -----
From: "Russell Dias" <rus321@xxxxxxxxx>
Date: Thu, Oct 21, 2010 11:03
Subject: [PHP] "My truth comes out" [1]
To: "ash@xxxxxxxxxxxxxxxxxxxx" <ash@xxxxxxxxxxxxxxxxxxxx>
Cc: <php-general@xxxxxxxxxxxxx>


I'm curious to know why 'thats as bad as an if' ?

It's simple, concise, understandble and does the job. So, I'm curious
to know why exactly its bad?

On Thu, Oct 21, 2010 at 8:01 PM, ash@xxxxxxxxxxxxxxxxxxxx
<ash@xxxxxxxxxxxxxxxxxxxx> wrote:
> That's as bad as an if!
>
> What about using settype() on the string? I've not tested it, but it looks like it should do the trick.
>
> Thanks,
> Ash
> http://www.ashleysheridan.co.uk
>
> ----- Reply message -----
> From: "Russell Dias" <rus321@xxxxxxxxx>
> Date: Thu, Oct 21, 2010 10:51
> Subject: [PHP] "My truth comes out" [1]
> To: <php-general@xxxxxxxxxxxxx>
>
> preg_match("/false/i", $string) ? false : true;
>
>
>
> On Thu, Oct 21, 2010 at 7:39 PM, Gary <php-general@xxxxxxxxxxxxxxx> wrote:
>> Is there any nice way to convert a string containing either "TRUE" or
>> "FALSE" to a bool with the appropriate value? I know I can just "if
>> (strcmp..." but, as the song goes on to say "...ugly, so ugly, it's ugly"[1]
>>
>> Footnotes:
>> [1] Â"Mask", Henry Rollins
>>
>> --
>> Gary
>>
>>
>> --
>> PHP General Mailing List (http://www.php.net/)
>> To unsubscribe, visit: http://www.php.net/unsub.php
>>
>>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux