[prev in list] [next in list] [prev in thread] [next in thread] 

List:       nyphp-talk
Subject:    Re: [nyphp-talk] Best practices for combining paths?
From:       Brent Baisley <brenttech () gmail ! com>
Date:       2009-03-31 21:10:17
Message-ID: 5d515c620903311410r2b85c2egb53f82b138b94817 () mail ! gmail ! com
[Download RAW message or body]

You don't need a library to fix that issue. Just use one of the trim
functions to trim the trailing / and add you own. If there is no
trailing slash, trim will do nothing.

$url_base= rtrim($url_base, '/').'/';


On Mon, Mar 30, 2009 at 5:22 PM, Paul A Houle <paul@devonianfarm.com> wrote:
> I pretty frequently write code like
>
> $url_base="http://somesite.com/system/controller";
> $path="object_type/verb.modifier/object_id";
> $url="{$url_base}/{$path}";
>
> note that this working correctly depends sensitively on how paths are used,
>  for instance,  if somebody puts a slash at the end of $url_base,  you wind
> up with a double slash in the path.  That doesn't usually have a disasterous
> effect,  but I'm a stickler about url canonicalizaton.
>
> My question is,  am I missing a good PHP built-in for combining parts of
> URLs or filesystem paths?  Is there a good library I should use?
>
> _______________________________________________
> New York PHP User Group Community Talk Mailing List
> http://lists.nyphp.org/mailman/listinfo/talk
>
> http://www.nyphp.org/show_participation.php
>
_______________________________________________
New York PHP User Group Community Talk Mailing List
http://lists.nyphp.org/mailman/listinfo/talk

http://www.nyphp.org/show_participation.php

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic