Jani Taskinen wrote:
Paweł Stradomski kirjoitti:
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.
You people are funny..
I'd like to have such a function in PHP, but when you think about how
easy it is to create without bloating the PHP core, it's easy enough to
do without it. Here's what I do using my own string library:
if (LS_Util_String :: ends_with($path, '.php')) {
...
}
It's a bit longer, but all my functions are longer for good reason:
http://www.dantescode.com/2007/10/10/evolution-of-php-coder-naming-classes/
-- Dante
--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php