Re: [RFC] Deprecations for PHP 8.4

From: Date: Tue, 25 Jun 2024 20:51:45 +0000
Subject: Re: [RFC] Deprecations for PHP 8.4
References: 1 2  Groups: php.internals 
Request: Send a blank email to internals+get-123844@lists.php.net to get a copy of this message
On Tuesday, 25 June 2024 at 19:06, Mike Schinkel <mike@newclarity.net> wrote: > strtok() > ===== > strtok() is found 35k times in GitHub: > >> >> https://github.com/search?q=md5%28+language%3APHP+&type=code > > It is a commonly used as a "left part of string up to a character" in addition to its > intended use for tokenizing. > > I would prefer not deprecated because of BC breakage, but IF it is deprecated I would suggest > adding a one-for-one replacement function for the "left part of string up to a character" > use-case; maybe str_left("abc.txt",".") > returning "abc". For this exact case of extracting a file name without an extension, you should really just use: pathinfo ( $filepath , PATHINFO_FILENAME); But for something more generic, you can just do: explode($delimiter, $str)[0]; So I really don't see why we would need an "str_left()" function. Best regards, Gina P. Banyard

« previous php.internals (#123844) next »