Re: New string functions: str_startswith() and str_endswith()

From: Date: Mon, 21 Jul 2008 21:18:07 +0000
Subject: Re: New string functions: str_startswith() and str_endswith()
References: 1 2 3 4  Groups: php.internals 
Request: Send a blank email to internals+get-39152@lists.php.net to get a copy of this message
On Mon, 2008-07-21 at 22:06 +0200, 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) Then $extension is a CV which isn't that much slower in comparison as a CONST, so from engine-performance-perspective: no big deal -> spend your time optimizing on other places where it has more effect than the time you loose on teaching people about all the fancy string functions (where we already have more than enough) > Readability would also increase. too many functions hurt more on readability imo ... johannes

« previous php.internals (#39152) next »