You are here: Re: parse_url questioin « PHP Programming Language « IT news, forums, messages
Re: parse_url questioin

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]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация