Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.php > #16374

Re: Handling parts of paths and directory names in PHP

From "Peter H. Coffin" <hellsop@ninehells.com>
Newsgroups comp.lang.php
Subject Re: Handling parts of paths and directory names in PHP
Date 2016-02-08 13:13 -0600
Message-ID <slrnnbhq6b.us5.hellsop@nibelheim.ninehells.com> (permalink)
References <n92n9n$3gq$1@dont-email.me> <87io22kgfe.fsf@bsb.me.uk>

Show all headers | View raw


On Fri, 05 Feb 2016 21:15:01 +0000, Ben Bacarisse wrote:
> James Harris <james.harris.1@gmail.com> writes:
>
>> Do you guys have any generic recommendations on how to store paths
>> based on your experience of handling paths in PHP?
><snip>
>> When handling such path parts as strings there are issues over whether
>> to store slash characters at the start and end of a part or whether to
>> add the slash when they are combined. Related, is avoiding a resultant
>> path having a double slash (i.e. //) at any point.
>
> I would not store the slashes.  When I store paths as an array of
> components I store absolute paths with a "" as the first one.  Then the
> full path is just a join operation.

Funny, that's almost exactly the opposite of how I look at it. To me,
the vast, vast majority of the time, I'm always only going to be dealing
with the full path anyway, because mostly I care about the thing at the
end of the path, and don't really give a damn what the path itself is.
So spending time writing, then running, code to assemble and break down
paths every time I want to access the thing at the end just seems to
gain me very little. And the majority of the time that I care about
anything other than just the target at the end, what I care about is the
penultimate part, the directory the thing is in. And there's already a
built-in function for getting that, that I don't have to write and is
probably more efficient than I could do in PHP itself anyway.

-- 
34. I will not turn into a snake. It never helps.
	--Peter Anspach's list of things to do as an Evil Overlord

Back to comp.lang.php | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Handling parts of paths and directory names in PHP James Harris <james.harris.1@gmail.com> - 2016-02-05 17:51 +0000
  Re: Handling parts of paths and directory names in PHP Ben Bacarisse <ben.usenet@bsb.me.uk> - 2016-02-05 21:15 +0000
    Re: Handling parts of paths and directory names in PHP James Harris <james.harris.1@gmail.com> - 2016-02-05 22:28 +0000
    Re: Handling parts of paths and directory names in PHP "Peter H. Coffin" <hellsop@ninehells.com> - 2016-02-08 13:13 -0600
      Re: Handling parts of paths and directory names in PHP Ben Bacarisse <ben.usenet@bsb.me.uk> - 2016-02-08 21:27 +0000
  Re: Handling parts of paths and directory names in PHP Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2016-02-09 00:09 +0100
    Re: Handling parts of paths and directory names in PHP Jerry Stuckle <jstucklex@attglobal.net> - 2016-02-08 19:34 -0500

csiph-web