[thelist] PHP question... checking string length

Theodore Serbinski stanson at gmail.com
Fri Mar 25 12:14:42 CST 2005

> > if ($myString=='') // do something
> >
> > if (strlen($myString) == 0) // do something
> It's just a style issue, though. Any difference in execution time is
> not even worth mentioning. HOWEVER, if you want to test it:

Ok if it's a style issue that's no prob. I did a quick test and the if
($myString=='') came up to being roughly 60% faster than the strlen()

Which is a lot but doing this comparision, but 5000 times is marginal
(thousands of a second) so really doesn't matter.

Guess I'll stick to the simpler =='' method if there is no advantage
to to the strlen() method. Thanks guys!


More information about the thelist mailing list