Le 22/07/2015 20:57, Marco Pivetta a écrit : > On 22 July 2015 at 19:49, Sara Golemon <[email protected] > <mailto:[email protected]>> wrote: > > On Wed, Jul 22, 2015 at 4:55 AM, Remi Collet > <[email protected] <mailto:[email protected]>> wrote: >> See https://bugs.php.net/bug.php?id=70112 >> > I'm not inherently against it, but this really really sounds like > a job for a userspace function. > > function dirname_n($path, $n) { while (($path !== '.') && $n--) > $path = dirname($path); return $path; > }<http://www.php.net/unsub.php> > > > Indeed. What need is there to add a functionality to a relatively > simple function like this one? What's the actual advantage that > cannot be achieved in userland code? >
Legibility and the frequency of the usage of dirname(dirname(... in various pieces of code. See https://github.com/search?q=dirname+__DIR__+language%3Aphp&ref=searchresults&type=Code&utf8=%E2%9C%93 As github search doesn't allow to search for (, I use __dir__ which probably hides more usage. As "n" is usually 2 or 3, nobody will write a userland function. Remi > Greets, > > Marco Pivetta > > http://twitter.com/Ocramius > > http://ocramius.github.com/ > -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php
