Paweł Stradomski wrote:
W liście Rasmus Lerdorf z dnia poniedziałek, 21 lipca 2008:
It also isn't any shorter:

    if(str_endswith($path,'.php'))

    vs.

    if(substr($path,-4)=='.php')

Only if comparing to a static string, but not for this case:

if (substr($path, -strlen($extension)) == $extension)

Readability would also increase.


In our code base, we have a nice file called string.php that has every variation of string functions not covered by the core in it. We add stuff as we need it. I break strings on the space nearest a given length in 80% of all code that runs on my server. But, I don't expect a PHP built in to do it. If you are worried about performance, you could make a PECL Strings package for all the stuff that the core does not do.

Then, your code can be readable and neat like you want.

Hmm, perhaps there is a need for a "standard" (widely used?) PHP (non-OO) package that filled in the gaps that the core does not provide. Make it non-OO so that it looks and acts like the core as much as possible. In my "spare time" I will start this. =)

--

Brian Moon
Senior Web Engineer
------------------------------
When you care enough to spend the very least.
http://dealnews.com/


--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to