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


Groups > comp.lang.php > #16362

Re: Handling parts of paths and directory names in PHP

Path csiph.com!eternal-september.org!feeder.eternal-september.org!mx02.eternal-september.org!.POSTED!not-for-mail
From Ben Bacarisse <ben.usenet@bsb.me.uk>
Newsgroups comp.lang.php
Subject Re: Handling parts of paths and directory names in PHP
Date Fri, 05 Feb 2016 21:15:01 +0000
Organization A noiseless patient Spider
Lines 27
Message-ID <87io22kgfe.fsf@bsb.me.uk> (permalink)
References <n92n9n$3gq$1@dont-email.me>
Mime-Version 1.0
Content-Type text/plain
Injection-Info mx02.eternal-september.org; posting-host="017616aa25f81ec581c44d76d61ba2f3"; logging-data="20390"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+98VNWMfaScYb9P59g9r3BpJ3BDH/gXHo="
Cancel-Lock sha1:RWexafIK6G626pSwldrisErovHA= sha1:xXPT7c1filN8e0glH2PWN5eB910=
X-BSB-Auth 1.4520efcaa1a50050b96c.20160205211501GMT.87io22kgfe.fsf@bsb.me.uk
Xref csiph.com comp.lang.php:16362

Show key headers only | View raw


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.

> These are mainly standard programming issues. I just wondered if you
> guys had come up with a consistent approach or whether you approach
> each problem separately.
>
> So, any recommendations as to whether to store each part of a path as
> a string or an array in PHP?

If you think it's worth it, wrap it in a class so you can easily change
your mind about that.  (I presume there's a typo in the question,
though.  If not, I've got the wrong end of the stick again.)

-- 
Ben.

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