[thelist] PHP question... checking string length

Theodore Serbinski stanson at gmail.com
Fri Mar 25 11:30:58 CST 2005


Guys, got a quick question. In PHP, I usually test if a string is empty like so:

if ($myString=='') // do something

But I recently stumbled upon some code from a much more experienced
PHP person test empty strings like so:

if (strlen($myString) == 0) // do something

Is there any difference/advantage to using one over the other? Only
apparently one is using the first method should be marginally faster
(no function call). Thanks!

ted


More information about the thelist mailing list