[nycphp-talk] Best practices for combining paths?
Brent Baisley
brenttech at gmail.com
Tue Mar 31 17:10:17 EDT 2009
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 at 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
>
More information about the talk
mailing list