|
Posted by Curtis on 02/12/07 08:30
deko wrote:
> Why does this code fail?
>
> $ref = http://example.com/?p=32
> $ref_a = parse_url($ref);
> echo ref_a['path']; //returns nothing
>
> Does the '?' cause parse_url to fail?
>
> I'm trying to capture a referrer in an user agent that contains a query
> string.
>
> As a work-around, I'm using this:
>
> $urlPath = stristr(substr($urlString, 9), '/');
>
> Other alternatives?
>
> Thanks in advance.
>
>
There are two syntax errors in your code:
1. $ref = http://example.com/?p=32 - you need quotes around this.
2. echo ref_a['path'] - you did not precede the variable name with $
Once you fix those, the path element has a value of "/".
Navigation:
[Reply to this message]
|