Path: csiph.com!eternal-september.org!feeder.eternal-september.org!mx02.eternal-september.org!.POSTED!not-for-mail From: Ben Bacarisse 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> References: 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 James Harris writes: > Do you guys have any generic recommendations on how to store paths > based on your experience of handling paths in PHP? > 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.