Re: New string functions: str_startswith() and str_endswith()
| From: | Paweł Stradomski | Date: | Mon, 21 Jul 2008 20:06:53 +0000 |
| Subject: | Re: New string functions: str_startswith() and str_endswith() | ||
| References: | 1 2 3 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-39143@lists.php.net to get a copy of this message | ||
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.
--
Paweł Stradomski