literal strings vs variable strings
am 13.08.2009 16:02:40 von Martin Scotta
--0016e6475438873b1304710663c6
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit
Hi all.
Is this going to save me anything?
foreach($items as $item)
if( 'something' == $item->something() )
return true;
$something = 'something';
foreach($items as $item)
if( $something == $item->something() )
return true;
--
Martin Scotta
--0016e6475438873b1304710663c6--
Re: literal strings vs variable strings
am 13.08.2009 16:17:28 von Ralph Deffke
I dont think so, because PHP is an interpreter, the string 'something' has
to be extracted and then be put in memory after that the code will compare
the two memory locations. doesnt give me any benefit.
however, comparing strings with the '==' does involve case sensitivity and
also leading or trailing spaces will guide to not equal. thats why I prefere
the comparison functions anyway
"Martin Scotta" wrote in message
news:6445d94e0908130702v4c2e5b77xe4b891546cc852c2@mail.gmail .com...
> Hi all.
>
> Is this going to save me anything?
>
>
> foreach($items as $item)
> if( 'something' == $item->something() )
> return true;
>
>
> $something = 'something';
> foreach($items as $item)
> if( $something == $item->something() )
> return true;
>
> --
> Martin Scotta
>
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php